chore: tape -> uvu tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Luke Edwards · committed by Luke Edwards · parent bc4f827 · Browse files · 4 files·+102 added−120 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+102 added−120 removed
- tests:+96 added−115 removed
- other:+6 added−5 removed
Provenance
- Commit
1c36d10- Tree
b5709c0- Author
Luke Edwards <luke.edwards05@gmail.com>- Committer
Luke Edwards <luke.edwards05@gmail.com>- Parent
bc4f827
4 files changed+102 added−120 removed
modified:.github/workflows/ci.yml+4 added-1 removed
6 unmodified lines7891011111213141511 unmodified lines272829303132333435363711 unmodified lines6 unmodified lines name: Node.js v${{ matrix.nodejs }} runs-on: ubuntu-latest strategy: matrix: nodejs: [6, 8, 10, 12, 14, 16] nodejs: [8, 10, 12, 14, 16] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with:11 unmodified lines - name: (coverage) Install if: matrix.nodejs >= 16 run: npm install -g nyc
- name: Build run: npm run build
- name: Test run: npm test if: matrix.nodejs < 16
11 unmodified linesmodified:test/classnames.js+39 added-51 removed
12345656788910119101112131415161714151617182021221920212225262723242526303132272829303536373132333440414243353637383946474840414243515253444546475657584849505161626352535455666768565758597172736061626376777864656667818268697071727312 unmodified lines8687888910310490919293/** * Ported from `classnames` for compatibility checks. */
import test from 'tape';import fn from '../src';import { test } from 'uvu';import * as assert from 'uvu/assert';import clsx from '../src';
test('(compat) keeps object keys with truthy values', t => { const out = fn({ a:true, b:false, c:0, d:null, e:undefined, f:1 }); t.is(out, 'a f'); t.end();test('(compat) keeps object keys with truthy values', () => { const out = clsx({ a:true, b:false, c:0, d:null, e:undefined, f:1 }); assert.is(out, 'a f');});
test('(compat) joins arrays of class names and ignore falsy values', t => { const out = fn('a', 0, null, undefined, true, 1, 'b'); t.is(out, 'a 1 b'); t.end();test('(compat) joins arrays of class names and ignore falsy values', () => { const out = clsx('a', 0, null, undefined, true, 1, 'b'); assert.is(out, 'a 1 b');});
test('(compat) supports heterogenous arguments', t => { t.is(fn({ a:true }, 'b', 0), 'a b'); t.end();test('(compat) supports heterogenous arguments', () => { assert.is(clsx({ a:true }, 'b', 0), 'a b');});
test('(compat) should be trimmed', t => { t.is(fn('', 'b', {}, ''), 'b'); t.end();test('(compat) should be trimmed', () => { assert.is(clsx('', 'b', {}, ''), 'b');});
test('(compat) returns an empty string for an empty configuration', t => { t.is(fn({}), ''); t.end();test('(compat) returns an empty string for an empty configuration', () => { assert.is(clsx({}), '');});
test('(compat) supports an array of class names', t => { t.is(fn(['a', 'b']), 'a b'); t.end();test('(compat) supports an array of class names', () => { assert.is(clsx(['a', 'b']), 'a b');});
test('(compat) joins array arguments with string arguments', t => { t.is(fn(['a', 'b'], 'c'), 'a b c'); t.is(fn('c', ['a', 'b']), 'c a b'); t.end();test('(compat) joins array arguments with string arguments', () => { assert.is(clsx(['a', 'b'], 'c'), 'a b c'); assert.is(clsx('c', ['a', 'b']), 'c a b');});
test('(compat) handles multiple array arguments', t => { t.is(fn(['a', 'b'], ['c', 'd']), 'a b c d'); t.end();test('(compat) handles multiple array arguments', () => { assert.is(clsx(['a', 'b'], ['c', 'd']), 'a b c d');});
test('(compat) handles arrays that include falsy and true values', t => { t.is(fn(['a', 0, null, undefined, false, true, 'b']), 'a b'); t.end();test('(compat) handles arrays that include falsy and true values', () => { assert.is(clsx(['a', 0, null, undefined, false, true, 'b']), 'a b');});
test('(compat) handles arrays that include arrays', t => { t.is(fn(['a', ['b', 'c']]), 'a b c'); t.end();test('(compat) handles arrays that include arrays', () => { assert.is(clsx(['a', ['b', 'c']]), 'a b c');});
test('(compat) handles arrays that include objects', t => { t.is(fn(['a', { b:true, c:false }]), 'a b'); t.end();test('(compat) handles arrays that include objects', () => { assert.is(clsx(['a', { b:true, c:false }]), 'a b');});
test('(compat) handles deep array recursion', t => { t.is(fn(['a', ['b', ['c', { d:true }]]]), 'a b c d'); t.end();test('(compat) handles deep array recursion', () => { assert.is(clsx(['a', ['b', ['c', { d:true }]]]), 'a b c d');});
test('(compat) handles arrays that are empty', t => { t.is(fn('a', []), 'a'); t.end();test('(compat) handles arrays that are empty', () => { assert.is(clsx('a', []), 'a');});
test('(compat) handles nested arrays that have empty nested arrays', t => { t.is(fn('a', [[]]), 'a'); t.end();test('(compat) handles nested arrays that have empty nested arrays', () => { assert.is(clsx('a', [[]]), 'a');});
test('(compat) handles all types of truthy and falsy property values as expected', t => { const out = fn({test('(compat) handles all types of truthy and falsy property values as expected', () => { const out = clsx({ // falsy: null: null, emptyString: '', noNumber: NaN,12 unmodified lines nonEmptyList: [1, 2, 3], greaterZero: 1 });
t.is(out, 'nonEmptyString whitespace function emptyObject nonEmptyObject emptyList nonEmptyList greaterZero'); t.end(); assert.is(out, 'nonEmptyString whitespace function emptyObject nonEmptyObject emptyList nonEmptyList greaterZero');});
test.run();modified:test/index.js+57 added-64 removed
1-import test from 'tape';1+// @ts-check2+import { test } from 'uvu';3+import * as assert from 'uvu/assert';4 import * as mod from '../src';5 6 const fn = mod.default;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 });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'), '');22 });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');29 });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');38 });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');45 });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');52 });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');59 });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');65 });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');72 });73 82-test('functions', t => {74+test('functions', () => {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');79 });80+81+test.run();modified:package.json+2 added-4 removed
16 unmodified lines17181920212221222324255 unmodified lines31323334363735363716 unmodified lines "node": ">=6" }, "scripts": { "build": "bundt", "pretest": "npm run build", "test": "tape -r esm test/*.js | tap-spec" "test": "uvu -r esm test" }, "files": [ "*.d.ts", "dist"5 unmodified lines ], "devDependencies": { "bundt": "1.0.1", "esm": "3.2.25", "tap-spec": "5.0.0", "tape": "4.9.1" "uvu": "0.5.4" }}