UNPKG

1.61 kBPlain TextView Raw
1import { list } from '../src/lists';
2import { rgb, hsl } from '../src/color';
3import { linearGradient } from '../src/gradient';
4import * as assert from 'assert';
5
6describe("csx/list", () => {
7 it("returns empty when no items", () => {
8 const empty = list();
9 assert.equal(empty, '');
10 });
11
12 it("returns the same item when passed one item", () => {
13 const single = list('single');
14 assert.equal(single, 'single');
15 });
16
17 it("returns a comma delimited list when passed multiple", () => {
18 const multiple = list(
19 'url(https://site)',
20 'local(My Font)'
21 );
22 assert.equal(multiple, 'url(https://site),local(My Font)');
23 });
24
25 it("calls .toString() on other helpers", () => {
26 const colorList = list(
27 rgb(255, 255, 0),
28 hsl(100, .5, .5)
29 );
30 assert.equal(colorList, 'rgb(255, 255, 0),hsl(100, 50%, 50%)');
31 });
32
33 it("removes empty entries", () => {
34 const holeyList = list(
35 'one',
36 undefined as any,
37 null as any,
38 'four',
39 '',
40 6
41 );
42 assert.equal(holeyList, 'one,four,6px');
43 });
44
45 it("calls .toString() on other helpers", () => {
46 const imageList = list(
47 linearGradient('top', 'red', 'blue'),
48 linearGradient('bottom', 'blue', 'red')
49 );
50 assert.equal(imageList, 'linear-gradient(top, red, blue),linear-gradient(bottom, blue, red)');
51 });
52
53 it("supports multiple helper types", () => {
54 const imageList = list(
55 linearGradient('top', 'red', 'blue'),
56 rgb(255, 255, 0).toString()
57 );
58 assert.equal(imageList, 'linear-gradient(top, red, blue),rgb(255, 255, 0)');
59 });
60});
\No newline at end of file