-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
convert.test.js
60 lines (55 loc) · 1.56 KB
/
convert.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
import { convert } from '../convert';
import { create } from '../create';
import darkThemeVars from '../themes/dark';
import lightThemeVars from '../themes/light';
describe('convert', () => {
it('should return the default theme when no params', () => {
const result = convert();
expect(result.base).toEqual('light');
});
it('should return a valid dark theme', () => {
const result = convert(darkThemeVars);
expect(result.base).toEqual('dark');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#2f2f2f',
}),
});
});
it('should return a valid light theme', () => {
const result = convert(lightThemeVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#F6F9FC',
}),
});
});
it('should map optional vars', () => {
const customVars = create({
base: 'light',
brandTitle: 'my custom storybook',
brandTarget: '_self',
gridCellSize: 12,
});
const result = convert(customVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
background: expect.objectContaining({
gridCellSize: 12,
}),
brand: expect.objectContaining({
title: 'my custom storybook',
target: '_self',
}),
});
});
});