Skip to content

Commit 6938e85

Browse files
committed
test(theme): remove duplicated objects
1 parent 3321ce9 commit 6938e85

File tree

1 file changed

+48
-98
lines changed

1 file changed

+48
-98
lines changed

core/src/utils/theme.spec.ts

Lines changed: 48 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,50 @@ import { Chip } from '../components/chip/chip';
66
import { generateComponentThemeCSS, generateCSSVars, generateGlobalThemeCSS, getCustomTheme, injectCSS } from './theme';
77

88
describe('getCustomTheme', () => {
9-
it('should return the custom theme if no mode overrides exist', () => {
10-
const customTheme = {
11-
radii: {
12-
sm: '14px',
13-
md: '18px',
14-
lg: '22px',
9+
const baseCustomTheme = {
10+
radii: {
11+
sm: '14px',
12+
md: '18px',
13+
lg: '22px',
14+
},
15+
components: {
16+
IonChip: {
17+
hue: {
18+
subtle: {
19+
bg: 'red',
20+
color: 'white',
21+
},
22+
},
1523
},
16-
components: {
17-
IonChip: {
18-
hue: {
19-
subtle: {
20-
bg: 'red',
21-
color: 'white',
22-
},
24+
},
25+
};
26+
27+
const iosOverride = {
28+
components: {
29+
IonChip: {
30+
hue: {
31+
subtle: {
32+
bg: 'blue',
2333
},
2434
},
2535
},
26-
};
36+
},
37+
};
38+
39+
const mdOverride = {
40+
components: {
41+
IonChip: {
42+
hue: {
43+
subtle: {
44+
bg: 'green',
45+
},
46+
},
47+
},
48+
},
49+
};
50+
51+
it('should return the custom theme if no mode overrides exist', () => {
52+
const customTheme = { ...baseCustomTheme };
2753

2854
const result = getCustomTheme(customTheme, 'ios');
2955

@@ -32,53 +58,15 @@ describe('getCustomTheme', () => {
3258

3359
it('should combine only with ios overrides if mode is ios', () => {
3460
const customTheme = {
35-
radii: {
36-
sm: '14px',
37-
md: '18px',
38-
lg: '22px',
39-
},
40-
components: {
41-
IonChip: {
42-
hue: {
43-
subtle: {
44-
bg: 'red',
45-
color: 'white',
46-
},
47-
},
48-
},
49-
},
50-
ios: {
51-
components: {
52-
IonChip: {
53-
hue: {
54-
subtle: {
55-
bg: 'blue',
56-
},
57-
},
58-
},
59-
},
60-
},
61-
md: {
62-
components: {
63-
IonChip: {
64-
hue: {
65-
subtle: {
66-
bg: 'green',
67-
},
68-
},
69-
},
70-
},
71-
},
61+
...baseCustomTheme,
62+
ios: iosOverride,
63+
md: mdOverride,
7264
};
7365

7466
const result = getCustomTheme(customTheme, 'ios');
7567

7668
const expected = {
77-
radii: {
78-
sm: '14px',
79-
md: '18px',
80-
lg: '22px',
81-
},
69+
...baseCustomTheme,
8270
components: {
8371
IonChip: {
8472
hue: {
@@ -96,53 +84,15 @@ describe('getCustomTheme', () => {
9684

9785
it('should combine only with md overrides if mode is md', () => {
9886
const customTheme = {
99-
radii: {
100-
sm: '14px',
101-
md: '18px',
102-
lg: '22px',
103-
},
104-
components: {
105-
IonChip: {
106-
hue: {
107-
subtle: {
108-
bg: 'red',
109-
color: 'white',
110-
},
111-
},
112-
},
113-
},
114-
ios: {
115-
components: {
116-
IonChip: {
117-
hue: {
118-
subtle: {
119-
bg: 'blue',
120-
},
121-
},
122-
},
123-
},
124-
},
125-
md: {
126-
components: {
127-
IonChip: {
128-
hue: {
129-
subtle: {
130-
bg: 'green',
131-
},
132-
},
133-
},
134-
},
135-
},
87+
...baseCustomTheme,
88+
ios: iosOverride,
89+
md: mdOverride,
13690
};
13791

13892
const result = getCustomTheme(customTheme, 'md');
13993

14094
const expected = {
141-
radii: {
142-
sm: '14px',
143-
md: '18px',
144-
lg: '22px',
145-
},
95+
...baseCustomTheme,
14696
components: {
14797
IonChip: {
14898
hue: {

0 commit comments

Comments
 (0)