forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-assert-colors.js
More file actions
70 lines (63 loc) · 1.88 KB
/
Copy pathtest-assert-colors.js
File metadata and controls
70 lines (63 loc) · 1.88 KB
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
68
69
70
'use strict';
require('../common');
const assert = require('assert/strict');
function setup() {
process.env.FORCE_COLOR = '1';
delete process.env.NODE_DISABLE_COLORS;
delete process.env.NO_COLOR;
}
assert.throws(() => {
setup();
assert.deepStrictEqual([1, 2, 2, 2, 2], [2, 2, 2, 2, 2]);
}, (err) => {
const expected = 'Expected values to be strictly deep-equal:\n' +
'\x1B[32m+ actual\x1B[39m \x1B[31m- expected\x1B[39m\n' +
'\n' +
'\x1B[39m [\n' +
'\x1B[32m+\x1B[39m 1,\n' +
'\x1B[39m 2,\n' +
'\x1B[39m 2,\n' +
'\x1B[39m 2,\n' +
'\x1B[39m 2,\n' +
'\x1B[31m-\x1B[39m 2\n' +
'\x1B[39m ]\n';
assert.strictEqual(err.message, expected);
return true;
});
{
assert.throws(() => {
setup();
assert.partialDeepStrictEqual({ a: 1, b: 2, c: 3, d: 5 }, { z: 4, b: 5 });
}, (err) => {
const expected = 'Expected values to be partially and strictly deep-equal:\n' +
'\x1B[90mactual\x1B[39m \x1B[31m- expected\x1B[39m\n' +
'\n' +
'\x1B[39m {\n' +
'\x1B[90m a: 1,\x1B[39m\n' +
'\x1B[90m b: 2,\x1B[39m\n' +
'\x1B[90m c: 3,\x1B[39m\n' +
'\x1B[90m d: 5\x1B[39m\n' +
'\x1B[31m-\x1B[39m b: 5,\n' +
'\x1B[31m-\x1B[39m z: 4\n' +
'\x1B[39m }\n';
assert.strictEqual(err.message, expected);
return true;
});
assert.throws(() => {
setup();
assert.partialDeepStrictEqual([1, 2, 3, 5], [4, 5]);
}, (err) => {
const expected = 'Expected values to be partially and strictly deep-equal:\n' +
'\x1B[90mactual\x1B[39m \x1B[31m- expected\x1B[39m\n' +
'\n' +
'\x1B[39m [\n' +
'\x1B[90m 1,\x1B[39m\n' +
'\x1B[90m 2,\x1B[39m\n' +
'\x1B[90m 3,\x1B[39m\n' +
'\x1B[31m-\x1B[39m 4,\n' +
'\x1B[39m 5\n' +
'\x1B[39m ]\n';
assert.strictEqual(err.message, expected);
return true;
});
}