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

code

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

18

lib/index.js

@@ -83,5 +83,6 @@ // Load modules

/* eslint-disable hapi/hapi-scope-start */
var method = internals.flags.indexOf(word) !== -1 ? function () { this._flags[word] = !this._flags[word]; return this; }
: function () { return this; };
/* eslint-enable hapi/hapi-scope-start */
Object.defineProperty(internals.Assertion.prototype, word, { get: method, configurable: true });

@@ -170,5 +171,14 @@ });

var compare = this._flags.deep ? function (a, b) { return Hoek.deepEqual(a, b, options); } :
function (a, b) { return a === b; };
var deepCompare = function (a, b) {
return Hoek.deepEqual(a, b, options);
};
var shallowCompare = function (a, b) {
return a === b;
};
var compare = this._flags.deep ? deepCompare : shallowCompare;
return this.assert(compare(this._ref, value), 'equal specified value', this._ref, value);

@@ -336,3 +346,3 @@ });

error = error || new Error();
var at = error.stack.split('\n').slice(1).filter(internals.filterLocal)[0].match(/^\s*at \(?(.+)\:(\d+)\:(\d+)\)?$/);
var at = error.stack.replace(error.toString(), '').split('\n').slice(1).filter(internals.filterLocal)[0].match(/^\s*at \(?(.+)\:(\d+)\:(\d+)\)?$/);
return {

@@ -339,0 +349,0 @@ filename: at[1],

{
"name": "code",
"description": "assertion library",
"version": "1.4.0",
"version": "1.4.1",
"repository": "git://github.com/hapijs/code",
"main": "index",
"main": "lib/index.js",
"keywords": [

@@ -25,8 +25,3 @@ "test",

},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/hapijs/code/raw/master/LICENSE"
}
]
"license": "BSD-3-Clause"
}

@@ -409,3 +409,3 @@ #code

Asserts that the reference value has a non-zero `length` property or an object with at least one key.
Asserts that the reference value has a `length` property equal to zero or an object with no keys.

@@ -412,0 +412,0 @@ ```js

@@ -146,6 +146,6 @@ // Load modules

catch (err) {
Code.settings.truncateMessages = origTruncate;
exception = err;
}
Code.settings.truncateMessages = origTruncate;
Hoek.assert(exception.message === 'Expected [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ] to be a string but got \'array\'', exception);

@@ -178,6 +178,6 @@ done();

catch (err) {
Code.settings.truncateMessages = origTruncate;
exception = err;
}
Code.settings.truncateMessages = origTruncate;
Hoek.assert(exception.message === 'Expected { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 } to be a string but got \'object\'', exception);

@@ -187,2 +187,19 @@ done();

it('handles multi-line error message', function (done) {
var exception = false;
var origTruncate = Code.settings.truncateMessages;
try {
Code.settings.truncateMessages = false;
Code.expect({ a: 1, b: '12345678901234567890123456789012345678901234567890' }).to.be.a.string();
}
catch (err) {
exception = err;
}
Code.settings.truncateMessages = origTruncate;
Hoek.assert(exception.message === 'Expected { a: 1,\n b: \'12345678901234567890123456789012345678901234567890\' } to be a string but got \'object\'', exception);
done();
});
it('asserts on invalid condition (long object values, display truncated)', function (done) {

@@ -211,6 +228,6 @@

catch (err) {
Code.settings.truncateMessages = origTruncate;
exception = err;
}
Code.settings.truncateMessages = origTruncate;
Hoek.assert(exception.message === 'Expected { a: 12345678901234567000, b: 12345678901234567000 } to be a string but got \'object\'', exception);

@@ -243,6 +260,6 @@ done();

catch (err) {
Code.settings.truncateMessages = origTruncate;
exception = err;
}
Code.settings.truncateMessages = origTruncate;
Hoek.assert(exception.message === 'Expected \'{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }\' to be a number but got \'string\'', exception);

@@ -1147,5 +1164,5 @@ done();

Code.expect(['abc']).to.deep.equal(['abc']);
Code.expect({a: 1}).to.deep.equal({a: 1});
Code.expect({}).to.not.deep.equal({a: 1});
Code.expect({a: 1}).to.not.deep.equal({});
Code.expect({ a: 1 }).to.deep.equal({ a: 1 });
Code.expect({}).to.not.deep.equal({ a: 1 });
Code.expect({ a: 1 }).to.not.deep.equal({});
Code.expect(Object.create(null)).to.not.deep.equal({});

@@ -1570,3 +1587,3 @@ Code.expect(Object.create(null)).to.deep.equal({}, { prototype: false });

function Custom() { } /* eslint func-style:0 */
function Custom () { } /* eslint func-style:0 */

@@ -1795,3 +1812,6 @@ var exception = false;

try {
Code.expect(function () { throw new Custom(); }).to.throw('kaboom');
Code.expect(function () {
throw new Custom();
}).to.throw('kaboom');
}

@@ -1824,3 +1844,6 @@ catch (err) {

try {
Code.expect(function () { throw new Error('kaboom'); }).to.throw('');
Code.expect(function () {
throw new Error('kaboom');
}).to.throw('');
}

@@ -1855,3 +1878,6 @@ catch (err) {

try {
Code.expect(function () { throw new Custom(); }).to.throw(Error);
Code.expect(function () {
throw new Custom();
}).to.throw(Error);
}

@@ -1858,0 +1884,0 @@ catch (err) {

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