assert-the-unexpected
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -75,2 +75,6 @@ var AssertionError = require('assert').AssertionError; | ||
function isNumber(x) { | ||
return !isNaN(Number(x)); | ||
} | ||
function isObject(x) { | ||
@@ -321,19 +325,22 @@ return typeof x === 'object'; | ||
function prepareEqual(actual, expected) { | ||
var a = !actual; | ||
var b = !expected; | ||
var a = actual; | ||
var b = expected; | ||
// undo the null and undefined evaluate equal | ||
if (!(a && b) && !(typeof actual === 'boolean' || typeof expected === 'boolean')) { | ||
a = actual; | ||
b = expected; | ||
if (isString(a) && isString(b)) { | ||
return { | ||
a: a, | ||
b: b | ||
}; | ||
} | ||
if ((Number(a) || Number(b)) && (isString(a) || isString(b))) { | ||
a = String(a); | ||
b = String(b); | ||
if ((isNumber(a) || isNumber(b)) && (isString(a) || isString(b))) { | ||
return { | ||
a: String(a), | ||
b: String(b) | ||
}; | ||
} | ||
return { | ||
a: a, | ||
b: b | ||
a: !!a, | ||
b: !!b | ||
}; | ||
@@ -340,0 +347,0 @@ } |
{ | ||
"name": "assert-the-unexpected", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "assert facade for Unexpected", | ||
@@ -5,0 +5,0 @@ "author": "Alex J Burke <alex@alexjeffburke.com>", |
@@ -87,2 +87,28 @@ var assert = require('../lib/assertTheUnexpected'); | ||
describe('equal', function () { | ||
it('should compare 0 and "0"', function () { | ||
expect(function () { | ||
assert.equal(0, '0'); | ||
}, 'not to error'); | ||
}); | ||
it('should compare 0 and false', function () { | ||
expect(function () { | ||
assert.equal(1, true); | ||
}, 'not to error'); | ||
}); | ||
it('should compare 1 and true', function () { | ||
expect(function () { | ||
assert.equal(1, true); | ||
}, 'not to error'); | ||
}); | ||
it('should compare null with itself', function () { | ||
expect(function () { | ||
assert.equal(null, null); | ||
}, 'not to error'); | ||
}); | ||
}); | ||
describe('ifError', function () { | ||
@@ -104,2 +130,10 @@ it('should pass on no error', function () { | ||
describe('notEqual', function () { | ||
it('should throw on matching number and string comparison', function () { | ||
expect(function () { | ||
assert.notEqual(0, '0'); | ||
}, 'to error'); | ||
}); | ||
}); | ||
describe('throws', function () { | ||
@@ -106,0 +140,0 @@ it('should pass on seeing an exception', function () { |
@@ -565,3 +565,1 @@ 'use strict'; | ||
}, new RegExp(`^AssertionError: '${'A'.repeat(127)} === ''$`)); | ||
console.log('All OK'); |
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
35451
950