Skip to content

Commit 92ebc19

Browse files
committed
1 parent 4c3cac5 commit 92ebc19

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

index.js

-1
This file was deleted.

lib/index.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ internals.Assertion.prototype.assert = function (result, verb, actual, expected)
8080

8181
[].concat(internals.flags, internals.grammar).forEach(function (word) {
8282

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

@@ -166,8 +167,17 @@ internals.addMethod('length', function (size) {
166167

167168
internals.addMethod(['equal', 'equals'], function (value, options) {
168169

169-
var compare = this._flags.deep ? function (a, b) { return Hoek.deepEqual(a, b, options); } :
170-
function (a, b) { return a === b; };
170+
var deepCompare = function (a, b) {
171+
172+
return Hoek.deepEqual(a, b, options);
173+
};
174+
175+
var shallowCompare = function (a, b) {
176+
177+
return a === b;
178+
};
179+
180+
var compare = this._flags.deep ? deepCompare : shallowCompare;
171181

172182
return this.assert(compare(this._ref, value), 'equal specified value', this._ref, value);
173183
});

package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "assertion library",
44
"version": "1.4.0",
55
"repository": "git://github.com/hapijs/code",
6-
"main": "index",
6+
"main": "lib/index",
77
"keywords": [
88
"test",
99
"expect",
@@ -22,10 +22,5 @@
2222
"test": "lab -v -t 100 -L",
2323
"test-cov-html": "lab -L -r html -o coverage.html"
2424
},
25-
"licenses": [
26-
{
27-
"type": "BSD",
28-
"url": "http://github.com/hapijs/code/raw/master/LICENSE"
29-
}
30-
]
25+
"license": "BSD-3-Clause"
3126
}

test/index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ describe('expect()', function () {
15611561

15621562
it('invalidates assertion (anonymous)', function (done) {
15631563

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

15661566
var exception = false;
15671567
try {
@@ -1785,7 +1785,10 @@ describe('expect()', function () {
17851785

17861786
var exception = false;
17871787
try {
1788-
Code.expect(function () { throw new Custom(); }).to.throw('kaboom');
1788+
Code.expect(function () {
1789+
1790+
throw new Custom();
1791+
}).to.throw('kaboom');
17891792
}
17901793
catch (err) {
17911794
exception = err;
@@ -1813,7 +1816,10 @@ describe('expect()', function () {
18131816

18141817
var exception = false;
18151818
try {
1816-
Code.expect(function () { throw new Error('kaboom'); }).to.throw('');
1819+
Code.expect(function () {
1820+
1821+
throw new Error('kaboom');
1822+
}).to.throw('');
18171823
}
18181824
catch (err) {
18191825
exception = err;
@@ -1843,7 +1849,10 @@ describe('expect()', function () {
18431849

18441850
var exception = false;
18451851
try {
1846-
Code.expect(function () { throw new Custom(); }).to.throw(Error);
1852+
Code.expect(function () {
1853+
1854+
throw new Custom();
1855+
}).to.throw(Error);
18471856
}
18481857
catch (err) {
18491858
exception = err;

0 commit comments

Comments
 (0)