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

Allow dates for isBelow and isAbove assertions #990

Merged
merged 17 commits into from
Jun 23, 2017
Prev Previous commit
Next Next commit
No parenthesis in should
  • Loading branch information
v1adko committed Jun 22, 2017
commit 4b5bb3c98b9a4e38a20dde6905ced4ea397d6742
82 changes: 41 additions & 41 deletions test/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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");
});

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup!

Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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(){
Expand All @@ -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");
});

Copy link
Contributor

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

Expand Down