Skip to content

Commit 56b9c4f

Browse files
committedFeb 18, 2021
chore: update test runner
1 parent 06a3b68 commit 56b9c4f

File tree

3 files changed

+75
-22
lines changed

3 files changed

+75
-22
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
.DS_Store
3+
*-lock.*
34
*.lock
45
*.log
56

‎package.json

+4-5
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 test/*.js | tap-spec"
21+
"test": "uvu -r esm test"
2322
},
2423
"files": [
2524
"dist"
@@ -37,8 +36,8 @@
3736
"serialize"
3837
],
3938
"devDependencies": {
40-
"bundt": "^0.1.1",
41-
"tap-spec": "^4.1.1",
42-
"tape": "^4.6.3"
39+
"bundt": "1.1.2",
40+
"esm": "3.2.25",
41+
"uvu": "0.5.1"
4342
}
4443
}

‎test/index.js

+70-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,75 @@
1-
const test = require('tape');
2-
const fn = require('../dist/obj-str');
1+
import { suite } from 'uvu';
2+
import * as assert from 'uvu/assert';
3+
import objstr from '../src';
34

4-
const one = true;
5-
const two = true;
6-
const bad = false;
7-
const key = 'abc';
5+
function is(input, expect) {
6+
assert.is(objstr(input), expect);
7+
}
88

9-
test('obj-str', t => {
10-
t.equal(typeof fn, 'function', 'exports a function');
9+
const API = suite('exports');
1110

12-
t.equal(fn(), '', 'returns empty string by default');
13-
t.equal(fn({}), '', `{} --> ''`);
14-
t.equal(fn({foo: true}), 'foo', `{ foo:true } --> foo`);
15-
t.equal(fn({foo: true, bar: false}), 'foo', `{ foo:true, bar:false } --> foo`);
16-
t.equal(fn({foo: 1 === 1, bar: 1 !== 1, baz: 1 !== 2}), 'foo baz', `{ foo:1===1, bar:1!==1, baz:1!==2 } --> foo baz`);
17-
t.equal(fn({one, two, bad}), 'one two', `{ one, two, bad } --> one two`);
18-
t.equal(fn({'-foo': true}), '-foo', `{ '-foo':true } --> -foo`);
19-
t.equal(fn({[key]: true}), 'abc', `{ [key]:true } --> abc`);
11+
API('should export a function', () => {
12+
assert.type(objstr, 'function');
13+
});
14+
15+
API.run();
16+
17+
// ---
18+
19+
const usage = suite('usage');
20+
21+
usage('true -> ""', () => {
22+
is(true, '');
23+
});
24+
25+
usage('false -> ""', () => {
26+
is(false, '');
27+
});
28+
29+
usage('undefined -> ""', () => {
30+
is(undefined, '');
31+
});
32+
33+
usage('null -> ""', () => {
34+
is(null, '');
35+
});
36+
37+
usage('{} -> ""', () => {
38+
is({}, '');
39+
});
2040

21-
t.end();
41+
usage('[] -> ""', () => {
42+
is([], '');
2243
});
44+
45+
usage('{ foo } -> "foo"', () => {
46+
is({ foo: true }, 'foo');
47+
is({ foo: 1 }, 'foo');
48+
});
49+
50+
usage('{ foo, bar } -> "foo"', () => {
51+
is({ foo: true, bar: false }, 'foo');
52+
is({ foo: 1, bar: 0 }, 'foo');
53+
});
54+
55+
usage('{ foo, bar, baz } -> "foo baz"', () => {
56+
is({ foo: 1 === 1, bar: 1 !== 1, baz: 1 !== 2 }, 'foo baz');
57+
is({ foo: assert, bar: null, baz: Date }, 'foo baz');
58+
});
59+
60+
usage('{ one, two, bad } -> "one two"', () => {
61+
let one=true, two=true, bad=false;
62+
is({ one, two, bad }, 'one two');
63+
});
64+
65+
usage('{ "-foo": x } -> "-foo"', () => {
66+
is({ '-foo': true }, '-foo');
67+
is({ '-foo': 0, '-foo': 1 }, '-foo');
68+
});
69+
70+
usage('{ [key]: x } -> key', () => {
71+
let key = 'abc';
72+
is({ [key]: true }, 'abc');
73+
});
74+
75+
usage.run();

0 commit comments

Comments
 (0)
Please sign in to comment.