|
| 1 | +const test = require('ava'); |
| 2 | + |
| 3 | +const passes = async (t, assertion, ...args) => { |
| 4 | + await t[assertion](...args); |
| 5 | +}; |
| 6 | + |
| 7 | +passes.title = (_, assertion, ...args) => `t.${assertion}(${args.map(v => JSON.stringify(v)).join(', ')}) passes`; |
| 8 | + |
| 9 | +test(passes, 'pass'); |
| 10 | +test(passes, 'is', 1, 1); |
| 11 | +test(passes, 'not', 1, 2); |
| 12 | +test(passes, 'deepEqual', {foo: 'bar'}, {foo: 'bar'}); |
| 13 | +test(passes, 'notDeepEqual', {foo: 'bar'}, {foo: 'baz'}); |
| 14 | +test(passes, 'throws', () => { |
| 15 | + throw new Error('error'); |
| 16 | +}); |
| 17 | +test(passes, 'throwsAsync', async () => { |
| 18 | + throw new Error('error'); |
| 19 | +}); |
| 20 | +test(passes, 'notThrows', () => {}); |
| 21 | +test(passes, 'notThrowsAsync', async () => {}); |
| 22 | +test(passes, 'snapshot', {foo: 'bar'}); |
| 23 | +test(passes, 'truthy', 1); |
| 24 | +test(passes, 'falsy', ''); |
| 25 | +test(passes, 'true', true); |
| 26 | +test(passes, 'false', false); |
| 27 | +test(passes, 'regex', 'foo', /foo/); |
| 28 | +test(passes, 'notRegex', 'bar', /foo/); |
| 29 | +test(passes, 'assert', 1); |
0 commit comments