-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
41 lines (34 loc) · 890 Bytes
/
index.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
const hex2tailwind = require('./index');
describe('Hex Color input formating', () => {
test('Hex has no #', () => {
expect(() => {
return hex2tailwind('34CCFF');
}).toThrow();
});
test('Hex is too long', () => {
expect(() => {
return hex2tailwind('#34CCCFF');
}).toThrow();
});
test('Hex is too short', () => {
expect(() => {
return hex2tailwind('#34');
}).toThrow();
});
test('Hex is not formated the right way', () => {
expect(() => {
return hex2tailwind('#34#CFF');
}).toThrow();
});
test('Input is a random string', () => {
expect(() => {
return hex2tailwind('random');
}).toThrow();
});
test('Input is #xxx Hex ', () => {
expect(hex2tailwind('#34C')).toBe('indigo-700');
});
test('Input is #xxxxxx Hex ', () => {
expect(hex2tailwind('#34C34C')).toBe('green-500');
});
});