Skip to content

Commit 1c36d10

Browse files
committed
chore: tape -> uvu tests
1 parent bc4f827 commit 1c36d10

File tree

4 files changed

+102
-120
lines changed

4 files changed

+102
-120
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
nodejs: [6, 8, 10, 12, 14, 16]
11+
nodejs: [8, 10, 12, 14, 16]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- uses: actions/setup-node@v2
@@ -28,6 +28,9 @@ jobs:
2828
if: matrix.nodejs >= 16
2929
run: npm install -g nyc
3030

31+
- name: Build
32+
run: npm run build
33+
3134
- name: Test
3235
run: npm test
3336
if: matrix.nodejs < 16

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
},
1919
"scripts": {
2020
"build": "bundt",
21-
"pretest": "npm run build",
22-
"test": "tape -r esm test/*.js | tap-spec"
21+
"test": "uvu -r esm test"
2322
},
2423
"files": [
2524
"*.d.ts",
@@ -33,7 +32,6 @@
3332
"devDependencies": {
3433
"bundt": "1.0.1",
3534
"esm": "3.2.25",
36-
"tap-spec": "5.0.0",
37-
"tape": "4.9.1"
35+
"uvu": "0.5.4"
3836
}
3937
}

test/classnames.js

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,71 @@
22
* Ported from `classnames` for compatibility checks.
33
*/
44

5-
import test from 'tape';
6-
import fn from '../src';
5+
import { test } from 'uvu';
6+
import * as assert from 'uvu/assert';
7+
import clsx from '../src';
78

8-
test('(compat) keeps object keys with truthy values', t => {
9-
const out = fn({ a:true, b:false, c:0, d:null, e:undefined, f:1 });
10-
t.is(out, 'a f');
11-
t.end();
9+
test('(compat) keeps object keys with truthy values', () => {
10+
const out = clsx({ a:true, b:false, c:0, d:null, e:undefined, f:1 });
11+
assert.is(out, 'a f');
1212
});
1313

14-
test('(compat) joins arrays of class names and ignore falsy values', t => {
15-
const out = fn('a', 0, null, undefined, true, 1, 'b');
16-
t.is(out, 'a 1 b');
17-
t.end();
14+
test('(compat) joins arrays of class names and ignore falsy values', () => {
15+
const out = clsx('a', 0, null, undefined, true, 1, 'b');
16+
assert.is(out, 'a 1 b');
1817
});
1918

20-
test('(compat) supports heterogenous arguments', t => {
21-
t.is(fn({ a:true }, 'b', 0), 'a b');
22-
t.end();
19+
test('(compat) supports heterogenous arguments', () => {
20+
assert.is(clsx({ a:true }, 'b', 0), 'a b');
2321
});
2422

25-
test('(compat) should be trimmed', t => {
26-
t.is(fn('', 'b', {}, ''), 'b');
27-
t.end();
23+
test('(compat) should be trimmed', () => {
24+
assert.is(clsx('', 'b', {}, ''), 'b');
2825
});
2926

30-
test('(compat) returns an empty string for an empty configuration', t => {
31-
t.is(fn({}), '');
32-
t.end();
27+
test('(compat) returns an empty string for an empty configuration', () => {
28+
assert.is(clsx({}), '');
3329
});
3430

35-
test('(compat) supports an array of class names', t => {
36-
t.is(fn(['a', 'b']), 'a b');
37-
t.end();
31+
test('(compat) supports an array of class names', () => {
32+
assert.is(clsx(['a', 'b']), 'a b');
3833
});
3934

40-
test('(compat) joins array arguments with string arguments', t => {
41-
t.is(fn(['a', 'b'], 'c'), 'a b c');
42-
t.is(fn('c', ['a', 'b']), 'c a b');
43-
t.end();
35+
test('(compat) joins array arguments with string arguments', () => {
36+
assert.is(clsx(['a', 'b'], 'c'), 'a b c');
37+
assert.is(clsx('c', ['a', 'b']), 'c a b');
4438
});
4539

46-
test('(compat) handles multiple array arguments', t => {
47-
t.is(fn(['a', 'b'], ['c', 'd']), 'a b c d');
48-
t.end();
40+
test('(compat) handles multiple array arguments', () => {
41+
assert.is(clsx(['a', 'b'], ['c', 'd']), 'a b c d');
4942
});
5043

51-
test('(compat) handles arrays that include falsy and true values', t => {
52-
t.is(fn(['a', 0, null, undefined, false, true, 'b']), 'a b');
53-
t.end();
44+
test('(compat) handles arrays that include falsy and true values', () => {
45+
assert.is(clsx(['a', 0, null, undefined, false, true, 'b']), 'a b');
5446
});
5547

56-
test('(compat) handles arrays that include arrays', t => {
57-
t.is(fn(['a', ['b', 'c']]), 'a b c');
58-
t.end();
48+
test('(compat) handles arrays that include arrays', () => {
49+
assert.is(clsx(['a', ['b', 'c']]), 'a b c');
5950
});
6051

61-
test('(compat) handles arrays that include objects', t => {
62-
t.is(fn(['a', { b:true, c:false }]), 'a b');
63-
t.end();
52+
test('(compat) handles arrays that include objects', () => {
53+
assert.is(clsx(['a', { b:true, c:false }]), 'a b');
6454
});
6555

66-
test('(compat) handles deep array recursion', t => {
67-
t.is(fn(['a', ['b', ['c', { d:true }]]]), 'a b c d');
68-
t.end();
56+
test('(compat) handles deep array recursion', () => {
57+
assert.is(clsx(['a', ['b', ['c', { d:true }]]]), 'a b c d');
6958
});
7059

71-
test('(compat) handles arrays that are empty', t => {
72-
t.is(fn('a', []), 'a');
73-
t.end();
60+
test('(compat) handles arrays that are empty', () => {
61+
assert.is(clsx('a', []), 'a');
7462
});
7563

76-
test('(compat) handles nested arrays that have empty nested arrays', t => {
77-
t.is(fn('a', [[]]), 'a');
78-
t.end();
64+
test('(compat) handles nested arrays that have empty nested arrays', () => {
65+
assert.is(clsx('a', [[]]), 'a');
7966
});
8067

81-
test('(compat) handles all types of truthy and falsy property values as expected', t => {
82-
const out = fn({
68+
test('(compat) handles all types of truthy and falsy property values as expected', () => {
69+
const out = clsx({
8370
// falsy:
8471
null: null,
8572
emptyString: '',
@@ -100,6 +87,7 @@ test('(compat) handles all types of truthy and falsy property values as expected
10087
greaterZero: 1
10188
});
10289

103-
t.is(out, 'nonEmptyString whitespace function emptyObject nonEmptyObject emptyList nonEmptyList greaterZero');
104-
t.end();
90+
assert.is(out, 'nonEmptyString whitespace function emptyObject nonEmptyObject emptyList nonEmptyList greaterZero');
10591
});
92+
93+
test.run();

test/index.js

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,81 @@
1-
import test from 'tape';
1+
// @ts-check
2+
import { test } from 'uvu';
3+
import * as assert from 'uvu/assert';
24
import * as mod from '../src';
35

46
const fn = mod.default;
57

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');
1515
});
1616

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'), '');
2322
});
2423

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');
3129
});
3230

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');
4138
});
4239

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');
4945
});
5046

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');
5752
});
5853

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');
6559
});
6660

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');
7265
});
7366

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');
8072
});
8173

82-
test('functions', t => {
74+
test('functions', () => {
8375
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');
8879
});
80+
81+
test.run();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy