Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SO-135] Fix falsely required param bug #325

Merged
merged 3 commits into from
May 28, 2019

Conversation

lag-of-death
Copy link
Contributor

SO-135

Checklist

  • Tests have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce

Bug fix.

What is the current behavior

When all of the required query parameters are provided (for a request), we get a false bug:
{"path":["query"],"code":"type","message":"should be string","severity":0}

Does this PR introduce a breaking change

No.

@philsturgeon
Copy link
Contributor

Is this related to #324 ?

Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just minor remarks.

packages/http/src/validator/__tests__/functional.spec.ts Outdated Show resolved Hide resolved
packages/http/src/validator/__tests__/functional.spec.ts Outdated Show resolved Hide resolved
@lag-of-death
Copy link
Contributor Author

@philsturgeon, no, not related to #324

output: BAD_OUTPUT,
}),
).toMatchSnapshot();
expect(await validator.validateOutput({ resource: httpOperations[1], output: BAD_OUTPUT })).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(await validator.validateOutput({ resource: httpOperations[1], output: BAD_OUTPUT })).toMatchSnapshot();
expect(validator.validateOutput({ resource: httpOperations[1], output: BAD_OUTPUT })).resolves.toMatchSnapshot();

Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lag-of-death lag-of-death merged commit a1c403c into master May 28, 2019
@lag-of-death lag-of-death deleted the SO-135_bugfix-for-falsely-required-param branch May 28, 2019 08:39
@philsturgeon
Copy link
Contributor

philsturgeon commented May 28, 2019 via email

@XVincentX
Copy link
Contributor

XVincentX commented May 28, 2019

@philsturgeon

you can return a promise

Not exactly. This still works because Jest has an internal queue (when using expect(promise).resolves) that will be used to track the status of the promise internally and correctly wait before moving to the next test. This, in mocha, would be a dangling handle (and a timeout error).

The truth, in general, for other test frameworks and for the JavaScript stuff in general — you should always return or store the promise.

@lag-of-death
Copy link
Contributor Author

lag-of-death commented May 28, 2019

@philsturgeon, I don't quite understand. I used await because validator.validateOutput returns a promise. And since I used await then I decorated the function with async. So, yeah, what are you trying to say?

@philsturgeon
Copy link
Contributor

The threading was lost because I replied via email. Don’t worry, it’s already merged. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants