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

assert-the-unexpected

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-the-unexpected - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

29

lib/assertTheUnexpected.js

@@ -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');
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