Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-datetime

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-datetime - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

100

chai-datetime.js

@@ -196,2 +196,19 @@ (function (plugin) {

chai.Assertion.addChainableMethod("beforeOrEqualDate", function (expected) {
var actual = this._obj;
this.assert(
chai.datetime.beforeDate(actual, expected) ||
chai.datetime.equalDate(actual, expected),
"expected " +
chai.datetime.formatDate(actual) +
" to be before or equal to " +
chai.datetime.formatDate(expected),
"expected " +
chai.datetime.formatDate(actual) +
" not to be before or equal to " +
chai.datetime.formatDate(expected)
);
});
chai.Assertion.addChainableMethod("afterDate", function (expected) {

@@ -213,2 +230,19 @@ var actual = this._obj;

chai.Assertion.addChainableMethod("afterOrEqualDate", function (expected) {
var actual = this._obj;
this.assert(
chai.datetime.afterDate(actual, expected) ||
chai.datetime.equalDate(actual, expected),
"expected " +
chai.datetime.formatDate(actual) +
" to be after or equal to " +
chai.datetime.formatDate(expected),
"expected " +
chai.datetime.formatDate(actual) +
" not to be after or equal to " +
chai.datetime.formatDate(expected)
);
});
chai.Assertion.addChainableMethod("withinDate", function (

@@ -253,2 +287,19 @@ expectedFrom,

chai.Assertion.addChainableMethod("beforeOrEqualTime", function (expected) {
var actual = this._obj;
this.assert(
chai.datetime.beforeTime(actual, expected) ||
chai.datetime.equalTime(actual, expected),
"expected " +
chai.datetime.formatTime(actual) +
" to be before or equal to " +
chai.datetime.formatTime(expected),
"expected " +
chai.datetime.formatTime(actual) +
" not to be before or equal to " +
chai.datetime.formatTime(expected)
);
});
chai.Assertion.addChainableMethod("afterTime", function (expected) {

@@ -270,2 +321,19 @@ var actual = this._obj;

chai.Assertion.addChainableMethod("afterOrEqualTime", function (expected) {
var actual = this._obj;
this.assert(
chai.datetime.afterTime(actual, expected) ||
chai.datetime.equalTime(actual, expected),
"expected " +
chai.datetime.formatTime(actual) +
" to be after or equal to " +
chai.datetime.formatTime(expected),
"expected " +
chai.datetime.formatTime(actual) +
" not to be after or equal to " +
chai.datetime.formatTime(expected)
);
});
chai.Assertion.addChainableMethod("withinTime", function (

@@ -313,2 +381,10 @@ expectedFrom,

assert.beforeOrEqualDate = function (val, exp, msg) {
new chai.Assertion(val, msg).to.be.beforeOrEqualDate(exp);
};
assert.notBeforeOrEqualDate = function (val, exp, msg) {
new chai.Assertion(val, msg).not.to.be.beforeOrEqualDate(exp);
};
assert.afterDate = function (val, exp, msg) {

@@ -322,2 +398,10 @@ new chai.Assertion(val, msg).to.be.afterDate(exp);

assert.afterOrEqualDate = function (val, exp, msg) {
new chai.Assertion(val, msg).to.be.afterOrEqualDate(exp);
};
assert.notAfterOrEqualDate = function (val, exp, msg) {
new chai.Assertion(val, msg).not.to.be.afterOrEqualDate(exp);
};
assert.withinDate = function (val, expFrom, expTo, msg) {

@@ -347,2 +431,10 @@ new chai.Assertion(val, msg).to.be.withinDate(expFrom, expTo);

assert.beforeOrEqualTime = function (val, exp, msg) {
new chai.Assertion(val, msg).to.be.beforeOrEqualTime(exp);
};
assert.notBeforeOrEqualTime = function (val, exp, msg) {
new chai.Assertion(val, msg).not.to.be.beforeOrEqualTime(exp);
};
assert.afterTime = function (val, exp, msg) {

@@ -356,2 +448,10 @@ new chai.Assertion(val, msg).to.be.afterTime(exp);

assert.afterOrEqualTime = function (val, exp, msg) {
new chai.Assertion(val, msg).to.be.afterOrEqualTime(exp);
};
assert.notAfterOrEqualTime = function (val, exp, msg) {
new chai.Assertion(val, msg).not.to.be.afterOrEqualTime(exp);
};
assert.withinTime = function (val, expFrom, expTo, msg) {

@@ -358,0 +458,0 @@ new chai.Assertion(val, msg).to.be.withinTime(expFrom, expTo);

2

package.json
{
"name": "chai-datetime",
"version": "1.6.0",
"version": "1.7.0",
"keywords": [

@@ -5,0 +5,0 @@ "chai",

@@ -53,7 +53,11 @@ # chai-datetime

* beforeTime
* beforeOrEqualTime
* afterTime
* afterOrEqualTime
* withinTime
* equalDate
* beforeDate
* beforeOrEqualDate
* afterDate
* afterOrEqualDate
* withinDate

@@ -60,0 +64,0 @@

@@ -413,2 +413,73 @@ (function (test) {

describe("beforeOrEqualDate", function () {
describe("when given two different date objects", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30);
this.d2 = new Date(2013, 4, 31);
});
it("passes", function () {
this.d1.should.be.beforeOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.beforeOrEqualDate(test.d2);
}.should.fail(
"expected Thu May 30 2013 not to be before or equal to Fri May 31 2013"
));
});
});
});
describe("when given two identical date objects", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30);
this.d2 = new Date(2013, 4, 30);
});
it("passes", function () {
this.d1.should.be.beforeOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.beforeOrEqualDate(test.d2);
}.should.fail(
"expected Thu May 30 2013 not to be before or equal to Thu May 30 2013"
));
});
});
});
describe("when given two identical dates but different times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 17);
this.d2 = new Date(2013, 4, 30, 18);
});
it("passes", function () {
this.d1.should.be.beforeOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.beforeOrEqualDate(test.d2);
}.should.fail(
"expected Thu May 30 2013 not to be before or equal to Thu May 30 2013"
));
});
});
});
});
describe("afterDate", function () {

@@ -485,2 +556,73 @@ describe("when given two different date objects", function () {

describe("afterOrEqualDate", function () {
describe("when given two different date objects", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 31);
this.d2 = new Date(2013, 4, 30);
});
it("passes", function () {
this.d1.should.be.afterOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.afterOrEqualDate(test.d2);
}.should.fail(
"expected Fri May 31 2013 not to be after or equal to Thu May 30 2013"
));
});
});
});
describe("when given two identical date objects", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30);
this.d2 = new Date(2013, 4, 30);
});
it("passes", function () {
this.d1.should.be.afterOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.afterOrEqualDate(test.d2);
}.should.fail(
"expected Thu May 30 2013 not to be after or equal to Thu May 30 2013"
));
});
});
});
describe("when given two identical date objects with different times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 17);
this.d2 = new Date(2013, 4, 30, 16);
});
it("passes", function () {
this.d1.should.be.afterOrEqualDate(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.afterOrEqualDate(test.d2);
}.should.fail(
"expected Thu May 30 2013 not to be after or equal to Thu May 30 2013"
));
});
});
});
});
describe("withinDate", function () {

@@ -614,2 +756,56 @@ describe("when given a date between two dates", function () {

describe("beforeOrEqualTime", function () {
describe("when comparing two different times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 16, 5, 0);
this.d2 = new Date(2013, 4, 30, 16, 5, 1);
});
it("passes", function () {
this.d1.should.be.beforeOrEqualTime(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.beforeOrEqualTime(test.d2);
}.should.fail(
"expected " +
chai.datetime.formatTime(this.d1) +
" not to be before or equal to " +
chai.datetime.formatTime(this.d2)
));
});
});
});
describe("when comparing identical times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 16, 5, 0);
this.d2 = new Date(2013, 4, 30, 16, 5, 0);
});
it("passes", function () {
this.d1.should.be.beforeOrEqualTime(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.beforeOrEqualTime(test.d2);
}.should.fail(
"expected " +
chai.datetime.formatTime(this.d1) +
" not to be before or equal to " +
chai.datetime.formatTime(this.d2)
));
});
});
});
});
describe("afterTime", function () {

@@ -669,2 +865,56 @@ describe("when comparing two different times", function () {

describe("afterOrEqualTime", function () {
describe("when comparing two different times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 16, 5, 1);
this.d2 = new Date(2013, 4, 30, 16, 5, 0);
});
it("passes", function () {
this.d1.should.be.afterOrEqualTime(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.afterOrEqualTime(test.d2);
}.should.fail(
"expected " +
chai.datetime.formatTime(this.d1) +
" not to be after or equal to " +
chai.datetime.formatTime(this.d2)
));
});
});
});
describe("when comparing two identical times", function () {
beforeEach(function () {
this.d1 = new Date(2013, 4, 30, 16, 5, 0);
this.d2 = new Date(2013, 4, 30, 16, 5, 0);
});
it("passes", function () {
this.d1.should.be.afterOrEqualTime(this.d2);
});
describe("when negated", function () {
it("fails", function () {
var test = this;
(function () {
test.d1.should.not.be.afterOrEqualTime(test.d2);
}.should.fail(
"expected " +
chai.datetime.formatTime(this.d1) +
" not to be after or equal to " +
chai.datetime.formatTime(this.d2)
));
});
});
});
});
describe("withinTime", function () {

@@ -858,2 +1108,10 @@ describe("when given a time between two times", function () {

it(".beforeOrEqualDate", function () {
assert.beforeOrEqualDate(this.subject, new Date(2013, 4, 31));
});
it(".notBeforeOrEqualDate", function () {
assert.notBeforeOrEqualDate(this.subject, new Date(2013, 4, 29));
});
it(".afterDate", function () {

@@ -867,2 +1125,10 @@ assert.afterDate(this.subject, new Date(2013, 4, 29));

it(".afterOrEqualDate", function () {
assert.afterOrEqualDate(this.subject, new Date(2013, 4, 29));
});
it(".notAfterOrEqualDate", function () {
assert.notAfterOrEqualDate(this.subject, new Date(2013, 4, 31));
});
it(".withinDate", function () {

@@ -900,2 +1166,10 @@ assert.withinDate(

it(".beforeOrEqualTime", function () {
assert.beforeOrEqualTime(this.subject, new Date(2013, 4, 30, 16, 5));
});
it(".notBeforeOrEqualTime", function () {
assert.notBeforeOrEqualTime(this.subject, new Date(2013, 4, 30, 16, 4));
});
it(".afterTime", function () {

@@ -909,2 +1183,10 @@ assert.afterTime(this.subject, new Date(2013, 4, 30, 16, 4));

it(".afterOrEqualTime", function () {
assert.afterOrEqualTime(this.subject, new Date(2013, 4, 30, 16, 5));
});
it(".notAfterOrEqualTime", function () {
assert.notAfterOrEqualTime(this.subject, new Date(2013, 4, 30, 16, 6));
});
it(".withinTime", function () {

@@ -911,0 +1193,0 @@ assert.withinTime(

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc