-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor tests related to notBefore and nbf (#492) #497
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
Conversation
ziluvatar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 😍
package.json
Outdated
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "nyc --reporter=html --reporter=text mocha && nsp check && cost-of-modules" | ||
| "test:unit": "nyc --reporter=html --reporter=text mocha", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 they are not unit tests. I guess you wanted a fast way to develop the tests getting coverage feedback without the delay of nsp + cost-of-modules, right? since this is test + coverage, let's name it: coverage or test:coverage or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! cost-of-modules temporarily renames the node_modules/ directory, and it was causing my editor to continually re-index. This was a way to run the tests without those checks.
I'm okay with a coverage task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in MitMaro@f564d20 before I squashed commits.
test/nbf.test.js
Outdated
| Infinity, | ||
| NaN, | ||
| // TODO empty string currently fails | ||
| // '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a test with the current behavior and a PR to fix this, since it should be invalid too (with same error message), and we can merge the fix on next major release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I understand correctly before I update:
- add a test for an empty string that checks for the
mserror - add another PR that fixes the behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in MitMaro@b037c26 before I squashed commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
test/nbf.test.js
Outdated
| // TODO should these fail in validation? | ||
| // -Infinity, | ||
| // Infinity, | ||
| // NaN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said, yes, I think they should fail, like I said before, let's add the current behavior and a PR (same one as before?) to fix in next major.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in MitMaro@b037c26 before I squashed commits.
9179675 to
b55f2ab
Compare
This change extracts all tests in the current files related to notBefore and nbf into a single test file. It also adds several missing related tests.
b55f2ab to
e529ca3
Compare
|
I fixed some of the formatting in MitMaro@943dab9 after fixing the issues noted above. |
First PR for #492.
This change extracts all tests in the current files related to
notBeforeandnbfinto a single test file. It also adds several missing related tests.I believe I removed all references to
nbfandnotBeforefrom the current tests.There are two TODOs in the tests, because I found a few unhandled cases that I expected would cause an error but did not. They are:Passing an empty string tonotBefore. I'm not sure if this should default to0or should throw an error. Currently it throws aval is not a non-empty string or a valid number. val=""fromms.Passing-Infinity,InfinityandNaNtonbf. These allJSON.stringifytonull, so I would assume should be considered invalid.Any suggestions of missing tests are more than welcome, and I will gladly add!