New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-expect

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-expect - npm Package Compare versions

Comparing version 1.17.0 to 1.20.0

.idea/.name

47

dist/jasmine-matchers.js

@@ -224,2 +224,31 @@ /*

/**
* Assert subject is a Date String conforming to the ISO 8601 standard
* @return {Boolean}
*/
matchers.toBeIso8601 = function() {
return matchers.toBeString.call(this)
&& this.actual.length >= 10
&& new Date(this.actual).toString() !== 'Invalid Date'
&& new Date(this.actual).toISOString().slice(0, this.actual.length) === this.actual;
};
/**
* Assert subject is a Date occurring before another Date
* @param {Date} date
* @return {Boolean}
*/
matchers.toBeBefore = function(date) {
return matchers.toBeDate.call(this) && matchers.toBeDate.call({ actual: date }) && this.actual.getTime() < date.getTime();
};
/**
* Assert subject is a Date occurring after another Date
* @param {Date} date
* @return {Boolean}
*/
matchers.toBeAfter = function(date) {
return matchers.toBeBefore.call({ actual: date }, this.actual);
};
// Errors

@@ -294,2 +323,20 @@ // ---------------------------------------------------------------------------

/**
* Assert value is >= floor or <= ceiling
* @param {Number} floor
* @param {Number} ceiling
* @return {Boolean}
*/
matchers.toBeWithinRange = function(floor, ceiling) {
return matchers.toBeNumber.call(this) && this.actual >= floor && this.actual <= ceiling;
};
/**
* Assert value is a number with no decimal places
* @return {Boolean}
*/
matchers.toBeWholeNumber = function() {
return matchers.toBeNumber.call(this) && (this.actual === 0 || this.actual % 1 === 0);
};
// Objects

@@ -296,0 +343,0 @@ // ---------------------------------------------------------------------------

2

package.json
{
"name": "jasmine-expect",
"version": "1.17.0",
"version": "1.20.0",
"description": "35+ additional matchers for the Jasmine BDD JavaScript test library",

@@ -5,0 +5,0 @@ "main": "jasmine-matchers.js",

@@ -85,6 +85,9 @@ # Jasmine-Matchers

expect(date).toBeDate()
expect(date).toBeBefore(date)
expect(date).toBeAfter(date)
expect(string).toBeIso8601()
## Usage
Just include a reference to the script after your reference to Jasmine.
Just include a reference to dist/jasmine-matchers.js after your reference to Jasmine.

@@ -91,0 +94,0 @@ ## License

@@ -8,1 +8,30 @@ /**

};
/**
* Assert subject is a Date String conforming to the ISO 8601 standard
* @return {Boolean}
*/
matchers.toBeIso8601 = function() {
return matchers.toBeString.call(this)
&& this.actual.length >= 10
&& new Date(this.actual).toString() !== 'Invalid Date'
&& new Date(this.actual).toISOString().slice(0, this.actual.length) === this.actual;
};
/**
* Assert subject is a Date occurring before another Date
* @param {Date} date
* @return {Boolean}
*/
matchers.toBeBefore = function(date) {
return matchers.toBeDate.call(this) && matchers.toBeDate.call({ actual: date }) && this.actual.getTime() < date.getTime();
};
/**
* Assert subject is a Date occurring after another Date
* @param {Date} date
* @return {Boolean}
*/
matchers.toBeAfter = function(date) {
return matchers.toBeBefore.call({ actual: date }, this.actual);
};

@@ -37,1 +37,19 @@ // Numbers

};
/**
* Assert value is >= floor or <= ceiling
* @param {Number} floor
* @param {Number} ceiling
* @return {Boolean}
*/
matchers.toBeWithinRange = function(floor, ceiling) {
return matchers.toBeNumber.call(this) && this.actual >= floor && this.actual <= ceiling;
};
/**
* Assert value is a number with no decimal places
* @return {Boolean}
*/
matchers.toBeWholeNumber = function() {
return matchers.toBeNumber.call(this) && (this.actual === 0 || this.actual % 1 === 0);
};

@@ -10,2 +10,49 @@ describe('Dates', function () {

describe('toBeIso8601', function () {
it('asserts value is a Date String conforming to the ISO 8601 standard', function () {
// format
expect('2013-07-08T07:29:15.863Z').toBeIso8601();
expect('2013-07-08T07:29:15.863').toBeIso8601();
expect('2013-07-08T07:29:15.').not.toBeIso8601();
expect('2013-07-08T07:29:15').toBeIso8601();
expect('2013-07-08T07:29:').not.toBeIso8601();
expect('2013-07-08T07:29').toBeIso8601();
expect('2013-07-08T07:2').not.toBeIso8601();
expect('2013-07-08T07:').not.toBeIso8601();
expect('2013-07-08T07').not.toBeIso8601();
expect('2013-07-08T').not.toBeIso8601();
expect('2013-07-08').toBeIso8601();
expect('2013-07-0').not.toBeIso8601();
expect('2013-07-').not.toBeIso8601();
expect('2013-07').not.toBeIso8601();
expect('2013-0').not.toBeIso8601();
expect('2013-').not.toBeIso8601();
expect('2013').not.toBeIso8601();
expect('201').not.toBeIso8601();
expect('20').not.toBeIso8601();
expect('2').not.toBeIso8601();
expect('').not.toBeIso8601();
// valid format, but impossible dates
expect('2013-99-12T00:00:00.000Z').not.toBeIso8601();
expect('2013-12-99T00:00:00.000Z').not.toBeIso8601();
expect('2013-01-01T99:00:00.000Z').not.toBeIso8601();
expect('2013-01-01T99:99:00.000Z').not.toBeIso8601();
expect('2013-01-01T00:00:99.000Z').not.toBeIso8601();
});
});
describe('toBeBefore', function () {
it('asserts value is a Date occurring before another Date', function () {
expect(new Date('2013-01-01T00:00:00.000Z')).toBeBefore(new Date('2013-01-01T01:00:00.000Z'));
expect(new Date('2013-01-01T01:00:00.000Z')).not.toBeBefore(new Date('2013-01-01T00:00:00.000Z'));
});
});
describe('toBeAfter', function () {
it('asserts value is a Date occurring after another Date', function () {
expect(new Date('2013-01-01T01:00:00.000Z')).toBeAfter(new Date('2013-01-01T00:00:00.000Z'));
expect(new Date('2013-01-01T00:00:00.000Z')).not.toBeAfter(new Date('2013-01-01T01:00:00.000Z'));
});
});
});

@@ -41,2 +41,26 @@ describe('Numbers', function() {

describe('toBeWithinRange', function () {
it('asserts value is a number >= floor or <= ceiling', function () {
expect(-3).not.toBeWithinRange(0, 2);
expect(-2).not.toBeWithinRange(0, 2);
expect(-1).not.toBeWithinRange(0, 2);
expect(0).toBeWithinRange(0, 2);
expect(1).toBeWithinRange(0, 2);
expect(2).toBeWithinRange(0, 2);
expect(3).not.toBeWithinRange(0, 2);
expect(NaN).not.toBeWithinRange(0, 2);
});
});
describe('toBeWholeNumber', function () {
it('asserts value is a number with no positive decimal places', function () {
expect(1).toBeWholeNumber();
expect(0).toBeWholeNumber();
expect(0.0).toBeWholeNumber();
expect(NaN).not.toBeWholeNumber();
expect(1.1).not.toBeWholeNumber();
expect(0.1).not.toBeWholeNumber();
});
});
});
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