Skip to content
Myr

index.js

This file

Path

test/index.js

96 lines · 2.7 KiB · JavaScript

Last changed by

chore: add `numbers` tests;Luke Edwardsbefore adoptionc520353

History of this file

Take it

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 1–3why, one step back
1// @ts-check
2import { test } from 'uvu';3import * as assert from 'uvu/assert';

feat: add named `clsx` export alias (#44)danikazebefore adoption56ab81f

line 4why, one step back
4import * as mod from '../src';

chore: import & add testsLuke Edwardsbefore adoption25fcd73

line 5why, one step back
5

feat: add named `clsx` export alias (#44)danikazebefore adoption56ab81f

lines 6–7why, one step back
6const fn = mod.default;
7

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 8–14why, one step back
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');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 15–16why, one step back
15});
16

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 17–21why, one step back
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'), '');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 22–23why, one step back
22});
23

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 24–28why, one step back
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');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 29–30why, one step back
29});
30

chore: add `numbers` tests;Luke Edwardsbefore adoptionc520353

lines 31–45why, one step back
31test('numbers', () => {
32 assert.is(fn(1), '1');33 assert.is(fn(12), '12');34 assert.is(fn(0.1), '0.1');35 assert.is(fn(0), '');3637 assert.is(fn(Infinity), 'Infinity');38 assert.is(fn(NaN), '');39});4041test('numbers (variadic)', () => {42 assert.is(fn(0, 1), '1');43 assert.is(fn(1, 2), '1 2');44});45

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 46–52why, one step back
46test('objects', () => {
47 assert.is(fn({}), '');48 assert.is(fn({ foo:true }), 'foo');49 assert.is(fn({ foo:true, bar:false }), 'foo');50 assert.is(fn({ foo:'hiya', bar:1 }), 'foo bar');51 assert.is(fn({ foo:1, bar:0, baz:1 }), 'foo baz');52 assert.is(fn({ '-foo':1, '--bar':1 }), '-foo --bar');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 53–54why, one step back
53});
54

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 55–59why, one step back
55test('objects (variadic)', () => {
56 assert.is(fn({}, {}), '');57 assert.is(fn({ foo:1 }, { bar:2 }), 'foo bar');58 assert.is(fn({ foo:1 }, null, { baz:1, bat:0 }), 'foo baz');59 assert.is(fn({ foo:1 }, {}, {}, { bar:'a' }, { baz:null, bat:Infinity }), 'foo bar bat');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 60–61why, one step back
60});
61

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 62–66why, one step back
62test('arrays', () => {
63 assert.is(fn([]), '');64 assert.is(fn(['foo']), 'foo');65 assert.is(fn(['foo', 'bar']), 'foo bar');66 assert.is(fn(['foo', 0 && 'bar', 1 && 'baz']), 'foo baz');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 67–68why, one step back
67});
68

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 69–73why, one step back
69test('arrays (nested)', () => {
70 assert.is(fn([[[]]]), '');71 assert.is(fn([[['foo']]]), 'foo');72 assert.is(fn([true, [['foo']]]), 'foo');;73 assert.is(fn(['foo', ['bar', ['', [['baz']]]]]), 'foo bar baz');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

lines 74–75why, one step back
74});
75

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 76–79why, one step back
76test('arrays (variadic)', () => {
77 assert.is(fn([], []), '');78 assert.is(fn(['foo'], ['bar']), 'foo bar');79 assert.is(fn(['foo'], null, ['baz', ''], true, '', []), 'foo baz');

chore: import & add testsLuke Edwardsbefore adoption25fcd73

line 80why, one step back
80});

fix: ignore function typesLuke Edwardsbefore adoption4aff569

line 81why, one step back
81

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 82–86why, one step back
82test('arrays (no `push` escape)', () => {
83 assert.is(fn({ push:1 }), 'push');84 assert.is(fn({ pop:true }), 'pop');85 assert.is(fn({ push:true }), 'push');86 assert.is(fn('hello', { world:1, push:true }), 'hello world push');

fix: use `Array.isArray` check;Luke Edwardsbefore adoption0d6023a

lines 87–88why, one step back
87});
88

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

line 89why, one step back
89test('functions', () => {

fix: ignore function typesLuke Edwardsbefore adoption4aff569

line 90why, one step back
90 const foo = () => {};

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 91–93why, one step back
91 assert.is(fn(foo, 'hello'), 'hello');
92 assert.is(fn(foo, 'hello', fn), 'hello');93 assert.is(fn(foo, 'hello', [[fn], 'world']), 'hello world');

fix: ignore function typesLuke Edwardsbefore adoption4aff569

line 94why, one step back
94});

chore: tape -> uvu testsLuke Edwardsbefore adoption1c36d10

lines 95–96why, one step back
95
96test.run();