Comparing version 0.1.0 to 0.1.1
var assert = require('assert'); | ||
var util = require('util'); | ||
var inspect = util.inspect; | ||
var isRegExp = util.isRegExp; | ||
var isArray = Array.isArray; | ||
@@ -10,10 +12,3 @@ module.exports = Expectation; | ||
* in a more natural style, without the need to remember the order of arguments. | ||
* This helps prevent you from making mistakes when writing tests. For example, | ||
* instead of writing: | ||
* | ||
* assert.equal(actual, expected, [message]) | ||
* | ||
* you can write | ||
* | ||
* expect(actual).toEqual(expected, [message]) | ||
* This helps prevent you from making mistakes when writing tests. | ||
*/ | ||
@@ -44,3 +39,3 @@ function Expectation(actual) { | ||
function toBeA(constructor, message) { | ||
assert(typeof constructor === 'function', 'The constructor used in toBeA must be a function'); | ||
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()); | ||
@@ -52,3 +47,3 @@ assert(this.actual instanceof constructor, message); | ||
function toMatch(pattern, message) { | ||
assert(util.isRegExp(pattern), 'The pattern used in toMatch must be a RegExp'); | ||
assert(isRegExp(pattern), 'The pattern used in toMatch must be a RegExp'); | ||
message = message || inspect(this.actual) + ' does not match ' + inspect(pattern); | ||
@@ -75,3 +70,3 @@ assert(pattern.test(this.actual), message); | ||
function toInclude(value, comparator, message) { | ||
assert(Array.isArray(this.actual), 'The actual value used in toContain/toInclude must be an Array'); | ||
assert(isArray(this.actual), 'The actual value used in toInclude/toContain must be an Array'); | ||
@@ -90,3 +85,3 @@ if (typeof comparator === 'string') { | ||
function toExclude(value, comparator, message) { | ||
assert(Array.isArray(this.actual), 'The actual value used in toNotContain/toExclude must be an Array'); | ||
assert(isArray(this.actual), 'The actual value used in toExclude/toNotContain must be an Array'); | ||
@@ -117,1 +112,5 @@ if (typeof comparator === 'string') { | ||
} | ||
function isFunction(object) { | ||
return typeof object === 'function'; | ||
} |
{ | ||
"name": "expect", | ||
"version": "0.1.0", | ||
"description": "Expect-style assertions for node", | ||
"version": "0.1.1", | ||
"description": "Write better assertions", | ||
"main": "expect.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"dependencies": {}, | ||
@@ -14,3 +11,3 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha spec" | ||
}, | ||
@@ -17,0 +14,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
7558
92