forked from vadimdemedes/tailwind-rn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
71 lines (62 loc) · 1.76 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import test from 'ava';
import tailwind, {getColor} from '.';
test('get styles for one class', t => {
t.deepEqual(tailwind('text-blue-500'), {color: 'rgba(66, 153, 225, 1)'});
});
test('get styles for multiple classes', t => {
t.deepEqual(tailwind('text-blue-500 bg-blue-100'), {
color: 'rgba(66, 153, 225, 1)',
backgroundColor: 'rgba(235, 248, 255, 1)'
});
});
test('ignore unknown classes', t => {
t.deepEqual(tailwind('text-blue-500 unknown'), {
color: 'rgba(66, 153, 225, 1)'
});
});
test('support color opacity', t => {
t.deepEqual(
tailwind(
'text-blue-500 text-opacity-50 bg-blue-100 bg-opacity-50 border-blue-100 border-opacity-50'
),
{
color: 'rgba(66, 153, 225, 0.5)',
backgroundColor: 'rgba(235, 248, 255, 0.5)',
borderTopColor: 'rgba(235, 248, 255, 0.5)',
borderRightColor: 'rgba(235, 248, 255, 0.5)',
borderBottomColor: 'rgba(235, 248, 255, 0.5)',
borderLeftColor: 'rgba(235, 248, 255, 0.5)'
}
);
});
test('ignore non-string values when transforming CSS variables', t => {
t.deepEqual(tailwind('bg-blue-500 p-12'), {
backgroundColor: 'rgba(66, 153, 225, 1)',
paddingTop: 48,
paddingRight: 48,
paddingBottom: 48,
paddingLeft: 48
});
});
test('get color value', t => {
t.is(getColor('blue-500'), 'rgba(66, 153, 225, 1)');
});
test('ignore no value param', t => {
t.deepEqual(tailwind(null), {});
t.deepEqual(tailwind(false), {});
t.deepEqual(tailwind(undefined), {});
t.deepEqual(tailwind(0), {});
});
test('ignore extra spaces', t => {
t.deepEqual(tailwind('text-blue-500 bg-blue-100'), {
color: 'rgba(66, 153, 225, 1)',
backgroundColor: 'rgba(235, 248, 255, 1)'
});
t.deepEqual(tailwind(`
text-blue-500
bg-blue-100
`), {
color: 'rgba(66, 153, 225, 1)',
backgroundColor: 'rgba(235, 248, 255, 1)'
});
});