-
Notifications
You must be signed in to change notification settings - Fork 68
/
index.js
67 lines (63 loc) · 2.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* power-assert.js - Power Assert in JavaScript.
*
* https://github.com/power-assert-js/power-assert
*
* Copyright (c) 2013-2018 Takuto Wada
* Licensed under the MIT license.
* https://github.com/power-assert-js/power-assert/blob/master/MIT-LICENSE.txt
*/
'use strict';
var baseAssert = require('assert');
var _deepEqual = require('universal-deep-strict-equal');
var empower = require('empower');
var formatter = require('power-assert-formatter');
var assign = require('xtend/mutable');
var define = require('define-properties');
var empowerOptions = {
modifyMessageOnRethrow: true,
saveContextOnRethrow: true
};
if (typeof baseAssert.deepStrictEqual !== 'function') {
baseAssert.deepStrictEqual = function deepStrictEqual (actual, expected, message) {
if (!_deepEqual(actual, expected, true)) {
baseAssert.fail(actual, expected, message, 'deepStrictEqual');
}
};
}
if (typeof baseAssert.notDeepStrictEqual !== 'function') {
baseAssert.notDeepStrictEqual = function notDeepStrictEqual (actual, expected, message) {
if (_deepEqual(actual, expected, true)) {
baseAssert.fail(actual, expected, message, 'notDeepStrictEqual');
}
};
}
function customize (customOptions) {
var options = customOptions || {};
var applyEmpower = function (fn) {
return empower(
fn,
formatter(options.output),
assign({}, empowerOptions, options.assertion)
);
};
var poweredAssert = applyEmpower(baseAssert);
poweredAssert.customize = customize;
if (typeof baseAssert.strict === 'function') {
poweredAssert.strict = applyEmpower(baseAssert.strict);
} else {
var strict = applyEmpower(baseAssert);
poweredAssert.strict = assign(strict, {
equal: strict.strictEqual,
deepEqual: strict.deepStrictEqual,
notEqual: strict.notStrictEqual,
notDeepEqual: strict.notDeepStrictEqual
});
}
poweredAssert.strict.strict = poweredAssert.strict;
return poweredAssert;
}
var defaultAssert = customize();
define(defaultAssert, { '__esModule': true });
defaultAssert['default'] = defaultAssert;
module.exports = defaultAssert;