|
1 |
| -import test from 'tape'; |
| 1 | +// @ts-check |
| 2 | +import { test } from 'uvu'; |
| 3 | +import * as assert from 'uvu/assert'; |
2 | 4 | import * as mod from '../src';
|
3 | 5 |
|
4 | 6 | const fn = mod.default;
|
5 | 7 |
|
6 |
| -test('exports', t => { |
7 |
| - t.is(typeof mod.default, 'function', 'exports default function'); |
8 |
| - t.is(typeof mod.clsx, 'function', 'exports named function'); |
9 |
| - t.ok(mod.default === mod.clsx, 'exports are equal'); |
10 |
| - |
11 |
| - t.is(typeof mod.default(), 'string', '~> returns string output'); |
12 |
| - t.is(typeof mod.clsx(), 'string', '~> returns string output'); |
13 |
| - |
14 |
| - t.end(); |
| 8 | +test('exports', () => { |
| 9 | + assert.type(mod.default, 'function', 'exports default function'); |
| 10 | + assert.type(mod.clsx, 'function', 'exports named function'); |
| 11 | + assert.is(mod.default, mod.clsx, 'exports are equal'); |
| 12 | + |
| 13 | + assert.type(mod.default(), 'string', '~> returns string output'); |
| 14 | + assert.type(mod.clsx(), 'string', '~> returns string output'); |
15 | 15 | });
|
16 | 16 |
|
17 |
| -test('strings', t => { |
18 |
| - t.is(fn(''), ''); |
19 |
| - t.is(fn('foo'), 'foo'); |
20 |
| - t.is(fn(true && 'foo'), 'foo'); |
21 |
| - t.is(fn(false && 'foo'), ''); |
22 |
| - t.end(); |
| 17 | +test('strings', () => { |
| 18 | + assert.is(fn(''), ''); |
| 19 | + assert.is(fn('foo'), 'foo'); |
| 20 | + assert.is(fn(true && 'foo'), 'foo'); |
| 21 | + assert.is(fn(false && 'foo'), ''); |
23 | 22 | });
|
24 | 23 |
|
25 |
| -test('strings (variadic)', t => { |
26 |
| - t.is(fn(''), ''); |
27 |
| - t.is(fn('foo', 'bar'), 'foo bar'); |
28 |
| - t.is(fn(true && 'foo', false && 'bar', 'baz'), 'foo baz'); |
29 |
| - t.is(fn(false && 'foo', 'bar', 'baz', ''), 'bar baz'); |
30 |
| - t.end(); |
| 24 | +test('strings (variadic)', () => { |
| 25 | + assert.is(fn(''), ''); |
| 26 | + assert.is(fn('foo', 'bar'), 'foo bar'); |
| 27 | + assert.is(fn(true && 'foo', false && 'bar', 'baz'), 'foo baz'); |
| 28 | + assert.is(fn(false && 'foo', 'bar', 'baz', ''), 'bar baz'); |
31 | 29 | });
|
32 | 30 |
|
33 |
| -test('objects', t => { |
34 |
| - t.is(fn({}), ''); |
35 |
| - t.is(fn({ foo:true }), 'foo'); |
36 |
| - t.is(fn({ foo:true, bar:false }), 'foo'); |
37 |
| - t.is(fn({ foo:'hiya', bar:1 }), 'foo bar'); |
38 |
| - t.is(fn({ foo:1, bar:0, baz:1 }), 'foo baz'); |
39 |
| - t.is(fn({ '-foo':1, '--bar':1 }), '-foo --bar'); |
40 |
| - t.end(); |
| 31 | +test('objects', () => { |
| 32 | + assert.is(fn({}), ''); |
| 33 | + assert.is(fn({ foo:true }), 'foo'); |
| 34 | + assert.is(fn({ foo:true, bar:false }), 'foo'); |
| 35 | + assert.is(fn({ foo:'hiya', bar:1 }), 'foo bar'); |
| 36 | + assert.is(fn({ foo:1, bar:0, baz:1 }), 'foo baz'); |
| 37 | + assert.is(fn({ '-foo':1, '--bar':1 }), '-foo --bar'); |
41 | 38 | });
|
42 | 39 |
|
43 |
| -test('objects (variadic)', t => { |
44 |
| - t.is(fn({}, {}), ''); |
45 |
| - t.is(fn({ foo:1 }, { bar:2 }), 'foo bar'); |
46 |
| - t.is(fn({ foo:1 }, null, { baz:1, bat:0 }), 'foo baz'); |
47 |
| - t.is(fn({ foo:1 }, {}, {}, { bar:'a' }, { baz:null, bat:Infinity }), 'foo bar bat'); |
48 |
| - t.end(); |
| 40 | +test('objects (variadic)', () => { |
| 41 | + assert.is(fn({}, {}), ''); |
| 42 | + assert.is(fn({ foo:1 }, { bar:2 }), 'foo bar'); |
| 43 | + assert.is(fn({ foo:1 }, null, { baz:1, bat:0 }), 'foo baz'); |
| 44 | + assert.is(fn({ foo:1 }, {}, {}, { bar:'a' }, { baz:null, bat:Infinity }), 'foo bar bat'); |
49 | 45 | });
|
50 | 46 |
|
51 |
| -test('arrays', t => { |
52 |
| - t.is(fn([]), ''); |
53 |
| - t.is(fn(['foo']), 'foo'); |
54 |
| - t.is(fn(['foo', 'bar']), 'foo bar'); |
55 |
| - t.is(fn(['foo', 0 && 'bar', 1 && 'baz']), 'foo baz'); |
56 |
| - t.end(); |
| 47 | +test('arrays', () => { |
| 48 | + assert.is(fn([]), ''); |
| 49 | + assert.is(fn(['foo']), 'foo'); |
| 50 | + assert.is(fn(['foo', 'bar']), 'foo bar'); |
| 51 | + assert.is(fn(['foo', 0 && 'bar', 1 && 'baz']), 'foo baz'); |
57 | 52 | });
|
58 | 53 |
|
59 |
| -test('arrays (nested)', t => { |
60 |
| - t.is(fn([[[]]]), ''); |
61 |
| - t.is(fn([[['foo']]]), 'foo'); |
62 |
| - t.is(fn([true, [['foo']]]), 'foo');; |
63 |
| - t.is(fn(['foo', ['bar', ['', [['baz']]]]]), 'foo bar baz'); |
64 |
| - t.end(); |
| 54 | +test('arrays (nested)', () => { |
| 55 | + assert.is(fn([[[]]]), ''); |
| 56 | + assert.is(fn([[['foo']]]), 'foo'); |
| 57 | + assert.is(fn([true, [['foo']]]), 'foo');; |
| 58 | + assert.is(fn(['foo', ['bar', ['', [['baz']]]]]), 'foo bar baz'); |
65 | 59 | });
|
66 | 60 |
|
67 |
| -test('arrays (variadic)', t => { |
68 |
| - t.is(fn([], []), ''); |
69 |
| - t.is(fn(['foo'], ['bar']), 'foo bar'); |
70 |
| - t.is(fn(['foo'], null, ['baz', ''], true, '', []), 'foo baz'); |
71 |
| - t.end(); |
| 61 | +test('arrays (variadic)', () => { |
| 62 | + assert.is(fn([], []), ''); |
| 63 | + assert.is(fn(['foo'], ['bar']), 'foo bar'); |
| 64 | + assert.is(fn(['foo'], null, ['baz', ''], true, '', []), 'foo baz'); |
72 | 65 | });
|
73 | 66 |
|
74 |
| -test('arrays (no `push` escape)', t => { |
75 |
| - t.is(fn({ push:1 }), 'push'); |
76 |
| - t.is(fn({ pop:true }), 'pop'); |
77 |
| - t.is(fn({ push:true }), 'push'); |
78 |
| - t.is(fn('hello', { world:1, push:true }), 'hello world push'); |
79 |
| - t.end(); |
| 67 | +test('arrays (no `push` escape)', () => { |
| 68 | + assert.is(fn({ push:1 }), 'push'); |
| 69 | + assert.is(fn({ pop:true }), 'pop'); |
| 70 | + assert.is(fn({ push:true }), 'push'); |
| 71 | + assert.is(fn('hello', { world:1, push:true }), 'hello world push'); |
80 | 72 | });
|
81 | 73 |
|
82 |
| -test('functions', t => { |
| 74 | +test('functions', () => { |
83 | 75 | const foo = () => {};
|
84 |
| - t.is(fn(foo, 'hello'), 'hello'); |
85 |
| - t.is(fn(foo, 'hello', fn), 'hello'); |
86 |
| - t.is(fn(foo, 'hello', [[fn], 'world']), 'hello world'); |
87 |
| - t.end(); |
| 76 | + assert.is(fn(foo, 'hello'), 'hello'); |
| 77 | + assert.is(fn(foo, 'hello', fn), 'hello'); |
| 78 | + assert.is(fn(foo, 'hello', [[fn], 'world']), 'hello world'); |
88 | 79 | });
|
| 80 | + |
| 81 | +test.run(); |
0 commit comments