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

expect

Package Overview
Dependencies
Maintainers
1
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

63

modules/expect.js
var assert = require('assert');
var util = require('util');
var inspect = util.inspect;
var isRegExp = util.isRegExp;
var inspect = require('util').inspect;
var isRegExp = require('util').isRegExp;
var isArray = Array.isArray;

@@ -53,34 +52,25 @@

Expectation.prototype.toBeA = toBeA;
Expectation.prototype.toBeAn = toBeA;
function toBeA(constructor, message) {
Expectation.prototype.toBeA = function (constructor, message) {
assert(isFunction(constructor), 'The constructor used in toBeA/toBeAn must be a function');
message = message || inspect(this.actual) + ' is not a ' + (constructor.name || constructor.toString());
assert(this.actual instanceof constructor, message);
}
};
Expectation.prototype.toMatch = toMatch;
function toMatch(pattern, message) {
Expectation.prototype.toMatch = function (pattern, message) {
assert(isRegExp(pattern), 'The pattern used in toMatch must be a RegExp');
message = message || inspect(this.actual) + ' does not match ' + inspect(pattern);
assert(pattern.test(this.actual), message);
}
};
Expectation.prototype.toBeLessThan = toBeLessThan;
Expectation.prototype.toBeFewerThan = toBeLessThan;
function toBeLessThan(value, message) {
Expectation.prototype.toBeLessThan = function (value, message) {
message = message || inspect(this.actual) + ' is not less than ' + inspect(value);
assert(this.actual < value, message);
}
};
Expectation.prototype.toBeGreaterThan = toBeGreaterThan;
Expectation.prototype.toBeMoreThan = toBeGreaterThan;
function toBeGreaterThan(value, message) {
Expectation.prototype.toBeGreaterThan = function (value, message) {
message = message || inspect(this.actual) + ' is not greater than ' + inspect(value);
assert(this.actual > value, message);
}
};
Expectation.prototype.toInclude = toInclude;
Expectation.prototype.toContain = toInclude;
function toInclude(value, comparator, message) {
Expectation.prototype.toInclude = function (value, comparator, message) {
assert(isArray(this.actual), 'The actual value used in toInclude/toContain must be an Array');

@@ -94,8 +84,10 @@

message = message || inspect(this.actual) + ' does not include ' + inspect(value);
assert(arrayContains(this.actual, value, comparator), message);
}
Expectation.prototype.toExclude = toExclude;
Expectation.prototype.toNotContain = toExclude;
function toExclude(value, comparator, message) {
assert(
arrayContains(this.actual, value, comparator),
message
);
};
Expectation.prototype.toExclude = function (value, comparator, message) {
assert(isArray(this.actual), 'The actual value used in toExclude/toNotContain must be an Array');

@@ -109,5 +101,20 @@

message = message || inspect(this.actual) + ' includes ' + inspect(value);
assert(!arrayContains(this.actual, value, comparator), message);
}
assert(
!arrayContains(this.actual, value, comparator),
message
);
};
var aliases = {
toBeAn: 'toBeA',
toBeFewerThan: 'toBeLessThan',
toBeMoreThan: 'toBeGreaterThan',
toContain: 'toInclude',
toNotContain: 'toExclude'
};
for (var alias in aliases)
Expectation.prototype[alias] = Expectation.prototype[aliases[alias]];
module.exports = Expectation;
{
"name": "expect",
"version": "1.0.1",
"version": "1.0.2",
"description": "Write better assertions",

@@ -5,0 +5,0 @@ "main": "modules/expect.js",

@@ -95,3 +95,3 @@ [![build status](https://secure.travis-ci.org/mjackson/expect.png)](http://travis-ci.org/mjackson/expect)

Please file issues on the [issue tracker on GitHub](https://github.com/machjs/mach/issues).
Please file issues on the [issue tracker on GitHub](https://github.com/mjackson/expect/issues).

@@ -98,0 +98,0 @@ ### Tests

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