-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
Allow dates for isBelow and isAbove assertions #990
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e277921
Fixed most tests
v1adko 1f2b171
Fix date uniformity (UTC)
v1adko c3718ea
Add comment
v1adko 4364d1d
Cleanup
v1adko 90c156a
Change extra functions (WIP)
v1adko ce63a96
Finished tests
v1adko 9d33702
Add master chai.js back
v1adko 365fa21
Uncomment failing tests
v1adko a5428a4
Update master and tests
v1adko ee3cefc
Actual seconds, duh
v1adko 5e6a33a
Refactor 'above'
v1adko 870a7f3
Update all methods
v1adko ccbaf82
More explicit error
v1adko fc56c36
Documentation - articles consistency
v1adko 5330208
Custom message test in assert
v1adko 4b5bb3c
No parenthesis in should
v1adko 6638ef4
Custom message for isAbove
v1adko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
No parenthesis in should
- Loading branch information
commit 4b5bb3c98b9a4e38a20dde6905ced4ea397d6742
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,29 +553,29 @@ describe('should', function() { | |
var beforeUTC = oneSecondBefore.toUTCString(); | ||
var afterUTC = oneSecondAfter.toUTCString(); | ||
|
||
(now).should.be.within(oneSecondBefore, oneSecondAfter); | ||
(now).should.be.within(now, oneSecondAfter); | ||
(now).should.be.within(now, now); | ||
(oneSecondAfter).should.not.be.within(oneSecondAfter, oneSecondBefore); | ||
now.should.be.within(oneSecondBefore, oneSecondAfter); | ||
now.should.be.within(now, oneSecondAfter); | ||
now.should.be.within(now, now); | ||
oneSecondAfter.should.not.be.within(oneSecondAfter, oneSecondBefore); | ||
|
||
err(function(){ | ||
(now).should.not.be.within(now, oneSecondAfter, 'blah'); | ||
now.should.not.be.within(now, oneSecondAfter, 'blah'); | ||
}, "blah: expected " + nowUTC + " to not be within " + nowUTC + ".." + afterUTC); | ||
|
||
err(function(){ | ||
(oneSecondBefore).should.be.within(now, oneSecondAfter, 'blah'); | ||
oneSecondBefore.should.be.within(now, oneSecondAfter, 'blah'); | ||
}, "blah: expected " + beforeUTC + " to be within " + nowUTC + ".." + afterUTC); | ||
|
||
err(function(){ | ||
([]).should.have.length.within(now, 100, 'blah'); | ||
}, "blah: the arguments to within must be numbers"); | ||
|
||
err(function(){ | ||
(now).should.have.lengthOf.within(50, now, 'blah'); | ||
now.should.have.lengthOf.within(50, now, 'blah'); | ||
}, "blah: expected " + nowUTC + " to have property 'length'"); | ||
|
||
err(function () { | ||
(now).should.have.length.within(5, 7); | ||
now.should.have.length.within(5, 7); | ||
}, "expected " + nowUTC + " to have property 'length'"); | ||
|
||
err(function () { | ||
|
@@ -587,19 +587,19 @@ describe('should', function() { | |
}, "blah: the arguments to within must be numbers"); | ||
|
||
err(function () { | ||
(now).should.be.within(1, now, 'blah'); | ||
now.should.be.within(1, now, 'blah'); | ||
}, "blah: the arguments to within must be dates"); | ||
|
||
err(function () { | ||
(now).should.not.be.within(now, 1, 'blah'); | ||
now.should.not.be.within(now, 1, 'blah'); | ||
}, "blah: the arguments to within must be dates"); | ||
|
||
err(function () { | ||
(now).should.not.be.within(null, now, 'blah'); | ||
now.should.not.be.within(null, now, 'blah'); | ||
}, "blah: the arguments to within must be dates"); | ||
|
||
err(function () { | ||
(now).should.not.be.within(now, null, 'blah'); | ||
now.should.not.be.within(now, null, 'blah'); | ||
}, "blah: the arguments to within must be dates"); | ||
}); | ||
|
||
|
@@ -655,33 +655,33 @@ describe('should', function() { | |
var oneSecondAgo = new Date(now.getTime() - 1000); | ||
var oneSecondAfter = new Date(now.getTime() + 1000); | ||
|
||
(now).should.be.above(oneSecondAgo); | ||
(oneSecondAfter).should.be.greaterThan(now); | ||
(now).should.not.be.above(oneSecondAfter); | ||
(oneSecondAgo).should.not.be.above(oneSecondAfter); | ||
now.should.be.above(oneSecondAgo); | ||
oneSecondAfter.should.be.greaterThan(now); | ||
now.should.not.be.above(oneSecondAfter); | ||
oneSecondAgo.should.not.be.above(oneSecondAfter); | ||
|
||
err(function(){ | ||
(now).should.be.above(oneSecondAfter, 'blah'); | ||
now.should.be.above(oneSecondAfter, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to be above " + oneSecondAfter.toUTCString()); | ||
|
||
err(function(){ | ||
(now).should.not.be.above(oneSecondAgo, 'blah'); | ||
now.should.not.be.above(oneSecondAgo, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to be at most " + oneSecondAgo.toUTCString()); | ||
|
||
err(function(){ | ||
(now).should.have.length.above(3, 'blah'); | ||
now.should.have.length.above(3, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to have property 'length'"); | ||
|
||
err(function(){ | ||
('string').should.have.length.above(now, 'blah'); | ||
}, "blah: the argument to above must be a number"); | ||
|
||
err(function () { | ||
(now).should.be.above(1, 'blah'); | ||
now.should.be.above(1, 'blah'); | ||
}, "blah: the argument to above must be a date"); | ||
|
||
err(function () { | ||
(now).should.be.above(null, 'blah'); | ||
now.should.be.above(null, 'blah'); | ||
}, "blah: the argument to above must be a date"); | ||
|
||
err(function () { | ||
|
@@ -782,37 +782,37 @@ describe('should', function() { | |
var oneSecondAgo = new Date(now.getTime() - 1000); | ||
var oneSecondAfter = new Date(now.getTime() + 1000); | ||
|
||
(now).should.be.below(oneSecondAfter); | ||
(oneSecondAgo).should.be.lessThan(now); | ||
(now).should.not.be.below(oneSecondAgo); | ||
(oneSecondAfter).should.not.be.below(oneSecondAgo); | ||
now.should.be.below(oneSecondAfter); | ||
oneSecondAgo.should.be.lessThan(now); | ||
now.should.not.be.below(oneSecondAgo); | ||
oneSecondAfter.should.not.be.below(oneSecondAgo); | ||
|
||
err(function(){ | ||
(now).should.be.below(now, 'blah'); | ||
now.should.be.below(now, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to be below " + now.toUTCString()); | ||
|
||
err(function(){ | ||
(now).should.not.be.below(oneSecondAfter, 'blah'); | ||
now.should.not.be.below(oneSecondAfter, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to be at least " + oneSecondAfter.toUTCString()); | ||
|
||
err(function(){ | ||
(now).should.have.length.below(3, 'blah'); | ||
now.should.have.length.below(3, 'blah'); | ||
}, "blah: expected " + now.toUTCString() + " to have property 'length'"); | ||
|
||
err(function () { | ||
(now).should.be.below(null, 'blah'); | ||
now.should.be.below(null, 'blah'); | ||
}, "blah: the argument to below must be a date"); | ||
|
||
err(function () { | ||
(1).should.not.be.below(now, 'blah'); | ||
}, "blah: the argument to below must be a number"); | ||
|
||
err(function () { | ||
(now).should.not.be.below(1, 'blah'); | ||
now.should.not.be.below(1, 'blah'); | ||
}, "blah: the argument to below must be a date"); | ||
|
||
err(function () { | ||
(now).should.not.be.below(null, 'blah'); | ||
now.should.not.be.below(null, 'blah'); | ||
}, "blah: the argument to below must be a date"); | ||
|
||
err(function () { | ||
|
@@ -873,16 +873,16 @@ describe('should', function() { | |
var beforeUTC = oneSecondBefore.toUTCString(); | ||
var afterUTC = oneSecondAfter.toUTCString(); | ||
|
||
(now).should.be.at.most(now); | ||
(now).should.be.at.most(oneSecondAfter); | ||
(now).should.not.be.at.most(oneSecondBefore); | ||
now.should.be.at.most(now); | ||
now.should.be.at.most(oneSecondAfter); | ||
now.should.not.be.at.most(oneSecondBefore); | ||
|
||
err(function(){ | ||
(now).should.be.at.most(oneSecondBefore, 'blah'); | ||
now.should.be.at.most(oneSecondBefore, 'blah'); | ||
}, "blah: expected " + nowUTC + " to be at most " + beforeUTC); | ||
|
||
err(function(){ | ||
(now).should.not.be.at.most(oneSecondAfter, 'blah'); | ||
now.should.not.be.at.most(oneSecondAfter, 'blah'); | ||
}, "blah: expected " + nowUTC + " to be above " + afterUTC); | ||
|
||
err(function(){ | ||
|
@@ -894,27 +894,27 @@ describe('should', function() { | |
}, "blah: the argument to most must be a number"); | ||
|
||
err(function () { | ||
(now).should.have.length.of.at.most(0, 'blah'); | ||
now.should.have.length.of.at.most(0, 'blah'); | ||
}, "blah: expected " + nowUTC + " to have property 'length'"); | ||
|
||
err(function () { | ||
(now).should.not.have.lengthOf.at.most(0, 'blah'); | ||
now.should.not.have.lengthOf.at.most(0, 'blah'); | ||
}, "blah: expected " + nowUTC + " to have property 'length'"); | ||
|
||
err(function () { | ||
(now).should.be.at.most(0, 'blah'); | ||
now.should.be.at.most(0, 'blah'); | ||
}, "blah: the argument to most must be a date"); | ||
|
||
err(function () { | ||
(now).should.be.at.most(null, 'blah'); | ||
now.should.be.at.most(null, 'blah'); | ||
}, "blah: the argument to most must be a date"); | ||
|
||
err(function () { | ||
(1).should.not.be.at.most(now, 'blah'); | ||
}, "blah: the argument to most must be a number"); | ||
|
||
err(function () { | ||
(now).should.not.be.at.most(undefined); | ||
now.should.not.be.at.most(undefined); | ||
}, "the argument to most must be a date"); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need parenthesis around |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't need parenthesis around
<var name>
whenever it's(<var name>).should
; still need parenthesis for the values plugged directly, like(0).should
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.
Ok, if I understood correctly, just omit parenthesis and do
now.should
instead of(now).should
?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.
Yup!