-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
assertionError.test.js
89 lines (68 loc) · 1.69 KB
/
assertionError.test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
const assert = require('assert');
test('assert', () => {
assert(false);
});
test('assert with a message', () => {
assert(false, 'this is a message');
});
test('assert.ok', () => {
assert.ok(false);
});
test('assert.ok with a message', () => {
assert.ok(false, 'this is a message');
});
test('assert.equal', () => {
assert.equal(1, 2);
});
test('assert.notEqual', () => {
assert.notEqual(1, 1);
});
test('assert.deepEqual', () => {
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 6}}});
});
test('assert.deepEqual with a message', () => {
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 7}}}, 'this is a message');
});
test('assert.notDeepEqual', () => {
assert.notDeepEqual({a: 1}, {a: 1});
});
test('assert.strictEqual', () => {
assert.strictEqual(1, NaN);
});
test('assert.notStrictEqual', () => {
assert.notStrictEqual(1, 1, 'My custom error message');
});
test('assert.deepStrictEqual', () => {
assert.deepStrictEqual({a: 1}, {a: 2});
});
test('assert.notDeepStrictEqual', () => {
assert.notDeepStrictEqual({a: 1}, {a: 1});
});
test('assert.ifError', () => {
assert.ifError(1);
});
test('assert.doesNotThrow', () => {
assert.doesNotThrow(() => {
throw Error('err!');
});
});
test('assert.throws', () => {
assert.throws(() => {});
});
test('async', async () => {
assert.equal('hello\ngoodbye', 'hello', 'hmmm');
});
test('assert.fail', () => {
assert.fail();
});
test('assert.fail with a message', () => {
assert.fail('error!');
});