Skip to content

Commit 8346294

Browse files
adding converted test
1 parent 87d8f35 commit 8346294

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import {
2+
useColumnErrorCheck,
3+
useDeepMerge,
4+
} from '../helpers';
5+
6+
describe('Helpers Composable', () => {
7+
8+
describe('useColumnErrorCheck', () => {
9+
describe('Errors', () => {
10+
const propName = 'columns';
11+
12+
it('should not throw an error when using correct column values', () => {
13+
const invokeCheck = () => {
14+
useColumnErrorCheck({
15+
columns: {
16+
lg: 12,
17+
md: 12,
18+
sm: 12,
19+
xl: 12,
20+
},
21+
propName: propName,
22+
});
23+
};
24+
25+
cy.wrap(null).then(() => {
26+
expect(invokeCheck).not.to.throw();
27+
});
28+
});
29+
30+
it('should fail if using incorrect column values', () => {
31+
const invokeCheck = () => {
32+
useColumnErrorCheck({
33+
columns: {
34+
lg: 120,
35+
md: 120,
36+
sm: 120,
37+
xl: 120,
38+
},
39+
propName: propName,
40+
});
41+
};
42+
43+
expect(() => useColumnErrorCheck({
44+
columns: {
45+
lg: 120,
46+
md: 120,
47+
sm: 120,
48+
xl: 120,
49+
},
50+
propName: propName,
51+
}));
52+
53+
cy.wrap(null).then(() => {
54+
expect(invokeCheck).to.throw(`The ${propName} values must be between 1 and 12`);
55+
});
56+
});
57+
});
58+
});
59+
60+
describe('useDeepMerge', () => {
61+
it('should deep merge 3 objects', () => {
62+
63+
const attrs = { class: 'foo-class' };
64+
65+
const injectedOptions = {
66+
autoPage: false,
67+
autoPageDelay: 1000,
68+
color: 'primary',
69+
density: 'compact',
70+
fieldColumns: {
71+
lg: 12,
72+
md: 12,
73+
sm: 6,
74+
},
75+
summaryColumns: {
76+
md: 12,
77+
sm: 6,
78+
},
79+
zed: {
80+
foo: {
81+
bar: 'baz',
82+
qux: 'qux',
83+
},
84+
},
85+
};
86+
87+
const props = {
88+
autoPage: true,
89+
autoPageDelay: 250,
90+
color: 'secondary',
91+
density: 'default',
92+
fieldColumns: {
93+
md: 6,
94+
sm: 12,
95+
},
96+
summaryColumns: {
97+
md: 6,
98+
sm: 12,
99+
},
100+
zed: {
101+
foo: {
102+
bar: 'biz',
103+
},
104+
},
105+
};
106+
107+
const mergedProps = useDeepMerge(attrs, injectedOptions, props);
108+
109+
expect(mergedProps).to.deep.equal({
110+
autoPage: true,
111+
autoPageDelay: 250,
112+
class: 'foo-class',
113+
color: 'secondary',
114+
density: 'default',
115+
fieldColumns: {
116+
lg: 12,
117+
md: 6,
118+
sm: 12,
119+
},
120+
summaryColumns: {
121+
md: 6,
122+
sm: 12,
123+
},
124+
zed: {
125+
foo: {
126+
bar: 'biz',
127+
qux: 'qux',
128+
},
129+
},
130+
});
131+
});
132+
});
133+
});

0 commit comments

Comments
 (0)