Skip to content
Myr

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

4 files+102 added−120 removed

modified:.github/workflows/ci.yml+4 added-1 removed
modified:test/classnames.js+39 added-51 removed
modified:test/index.js+57 added-64 removed
1import test from 'tape';1// @ts-check2import { test } from 'uvu';3import * as assert from 'uvu/assert';4import * as mod from '../src';56const fn = mod.default;76test('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();8test('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');1213 assert.type(mod.default(), 'string', '~> returns string output');14 assert.type(mod.clsx(), 'string', '~> returns string output');15});1617test('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();17test('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});2325test('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();24test('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});3033test('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();31test('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});3943test('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();40test('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});4651test('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();47test('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});5359test('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();54test('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});6067test('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();61test('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});6674test('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();67test('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});7382test('functions', t => {74test('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});8081test.run();
modified:package.json+2 added-4 removed