PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.21
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.21
1.4.21 1.4.20 1.4.19 1.4.18 1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 All 184 releases
disco / backend / views / components / Main / utilities / __tests__ / countdown-designs.test.js

countdown-designs.test.js in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.21, at backend/views/components/Main/utilities/__tests__/countdown-designs.test.js

202 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Tests for countdown-designs configuration
3 */
4 import {
5 countdownDesigns,
6 DEFAULT_COUNTDOWN_DESIGN,
7 } from '../count-down';
8
9 describe('countdown-designs', () => {
10 describe('DEFAULT_COUNTDOWN_DESIGN', () => {
11 it('should be defined', () => {
12 expect(DEFAULT_COUNTDOWN_DESIGN).toBeDefined();
13 });
14
15 it('should be a valid design key', () => {
16 expect(countdownDesigns[DEFAULT_COUNTDOWN_DESIGN]).toBeDefined();
17 });
18
19 it('should be design4', () => {
20 expect(DEFAULT_COUNTDOWN_DESIGN).toBe('design4');
21 });
22 });
23
24 describe('countdownDesigns', () => {
25 it('should have 4 designs', () => {
26 expect(Object.keys(countdownDesigns)).toHaveLength(4);
27 });
28
29 it('should have design1, design2, design3, design4', () => {
30 expect(countdownDesigns.design1).toBeDefined();
31 expect(countdownDesigns.design2).toBeDefined();
32 expect(countdownDesigns.design3).toBeDefined();
33 expect(countdownDesigns.design4).toBeDefined();
34 });
35
36 describe('design structure', () => {
37 Object.entries(countdownDesigns).forEach(([designKey, design]) => {
38 describe(`${designKey}`, () => {
39 it('should have an id', () => {
40 expect(design.id).toBe(designKey);
41 });
42
43 it('should have a name', () => {
44 expect(design.name).toBeDefined();
45 expect(typeof design.name).toBe('string');
46 });
47
48 it('should have hasSeparator boolean', () => {
49 expect(typeof design.hasSeparator).toBe('boolean');
50 });
51
52 it('should have singleContainer boolean', () => {
53 expect(typeof design.singleContainer).toBe('boolean');
54 });
55
56 it('should have container styles', () => {
57 expect(design.container).toBeDefined();
58 expect(design.container.background).toBeDefined();
59 expect(design.container.padding).toBeDefined();
60 expect(design.container['max-width']).toBe('370px');
61 });
62
63 it('should have title styles with text', () => {
64 expect(design.title).toBeDefined();
65 expect(design.title.text).toBeDefined();
66 expect(design.title.color).toBeDefined();
67 expect(design.title['font-size']).toBeDefined();
68 });
69
70 it('should have subtitle styles with text', () => {
71 expect(design.subtitle).toBeDefined();
72 expect(design.subtitle.text).toBeDefined();
73 expect(design.subtitle.color).toBeDefined();
74 });
75
76 it('should have box_container styles', () => {
77 expect(design.box_container).toBeDefined();
78 expect(design.box_container.display).toBe('flex');
79 });
80
81 it('should have box styles', () => {
82 expect(design.box).toBeDefined();
83 expect(design.box.background).toBeDefined();
84 expect(design.box['min-width']).toBeDefined();
85 });
86
87 it('should have number styles', () => {
88 expect(design.number).toBeDefined();
89 expect(design.number.color).toBeDefined();
90 expect(design.number['font-size']).toBeDefined();
91 expect(design.number['font-weight']).toBeDefined();
92 });
93
94 it('should have label styles', () => {
95 expect(design.label).toBeDefined();
96 expect(design.label.color).toBeDefined();
97 expect(design.label['font-size']).toBeDefined();
98 });
99
100 it('should have separator styles', () => {
101 expect(design.separator).toBeDefined();
102 expect(design.separator.color).toBeDefined();
103 expect(design.separator['font-size']).toBeDefined();
104 });
105 });
106 });
107 });
108
109 describe('design4 (default)', () => {
110 const design = countdownDesigns.design4;
111
112 it('should be marked as default', () => {
113 expect(design.isDefault).toBe(true);
114 });
115
116 it('should not have separator', () => {
117 expect(design.hasSeparator).toBe(false);
118 });
119
120 it('should not be single container', () => {
121 expect(design.singleContainer).toBe(false);
122 });
123
124 it('should have gradient background', () => {
125 expect(design.container.background).toContain('linear-gradient');
126 });
127 });
128
129 describe('design1', () => {
130 const design = countdownDesigns.design1;
131
132 it('should not be default', () => {
133 expect(design.isDefault).toBe(false);
134 });
135
136 it('should be single container', () => {
137 expect(design.singleContainer).toBe(true);
138 });
139
140 it('should not have separator', () => {
141 expect(design.hasSeparator).toBe(false);
142 });
143 });
144
145 describe('design2', () => {
146 const design = countdownDesigns.design2;
147
148 it('should not be default', () => {
149 expect(design.isDefault).toBe(false);
150 });
151
152 it('should not be single container', () => {
153 expect(design.singleContainer).toBe(false);
154 });
155
156 it('should have border', () => {
157 expect(design.container.border).toBe(1);
158 });
159 });
160
161 describe('design3', () => {
162 const design = countdownDesigns.design3;
163
164 it('should not be default', () => {
165 expect(design.isDefault).toBe(false);
166 });
167
168 it('should have separator', () => {
169 expect(design.hasSeparator).toBe(true);
170 });
171
172 it('should not be single container', () => {
173 expect(design.singleContainer).toBe(false);
174 });
175 });
176 });
177
178 describe('color consistency', () => {
179 Object.entries(countdownDesigns).forEach(([designKey, design]) => {
180 it(`${designKey} should have valid color values`, () => {
181 expect(design.title.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
182 expect(design.subtitle.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
183 expect(design.number.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
184 expect(design.label.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
185 expect(design.separator.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
186 });
187 });
188 });
189
190 describe('font sizes', () => {
191 Object.entries(countdownDesigns).forEach(([designKey, design]) => {
192 it(`${designKey} should have valid font size values`, () => {
193 expect(design.title['font-size']).toMatch(/^\d+px$/);
194 expect(design.subtitle['font-size']).toMatch(/^\d+px$/);
195 expect(design.number['font-size']).toMatch(/^\d+px$/);
196 expect(design.label['font-size']).toMatch(/^\d+px$/);
197 expect(design.separator['font-size']).toMatch(/^\d+px$/);
198 });
199 });
200 });
201 });
202