-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathhappy-path.js
45 lines (42 loc) · 1.06 KB
/
happy-path.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
import test from 'ava';
const passes = async (t, assertion, ...args) => {
await t[assertion](...args);
};
passes.title = (_, assertion, ...args) => `t.${assertion}(${args.map(v => JSON.stringify(v)).join(', ')}) passes`;
test(passes, 'pass');
test(passes, 'is', 1, 1);
test(passes, 'not', 1, 2);
test(passes, 'deepEqual', {foo: 'bar'}, {foo: 'bar'});
test(passes, 'notDeepEqual', {foo: 'bar'}, {foo: 'baz'});
test(passes, 'like', {
foo: 'bar',
deep: {
buz: 'qux',
extra: 'irrelevant',
},
extra: 'irrelevant',
deepExtra: {
extra: 'irrelevant',
},
}, {
foo: 'bar',
deep: {
buz: 'qux',
},
});
test(passes, 'throws', () => {
throw new Error('error');
});
test(passes, 'throwsAsync', async () => {
throw new Error('error');
});
test(passes, 'notThrows', () => {});
test(passes, 'notThrowsAsync', async () => {});
test(passes, 'snapshot', {foo: 'bar'});
test(passes, 'truthy', 1);
test(passes, 'falsy', '');
test(passes, 'true', true);
test(passes, 'false', false);
test(passes, 'regex', 'foo', /foo/);
test(passes, 'notRegex', 'bar', /foo/);
test(passes, 'assert', 1);