@afixt/test-utils 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/CLAUDE.md +1 -1
- package/README.md +40 -1
- package/docs/arrayUtils.js.html +8 -13
- package/docs/colorConversions.js.html +238 -0
- package/docs/constants.js.html +671 -0
- package/docs/cssUtils.js.html +80 -0
- package/docs/data/search.json +1 -1
- package/docs/domUtils.js.html +252 -32
- package/docs/formUtils.js.html +161 -0
- package/docs/getAccessibleName.js.html +215 -120
- package/docs/getAccessibleText.js.html +103 -48
- package/docs/getAriaAttributesByElement.js.html +4 -4
- package/docs/getCSSGeneratedContent.js.html +50 -41
- package/docs/getComputedRole.js.html +8 -3
- package/docs/getFocusableElements.js.html +25 -21
- package/docs/getGeneratedContent.js.html +24 -13
- package/docs/getImageText.js.html +31 -9
- package/docs/getStyleObject.js.html +7 -3
- package/docs/global.html +1 -1
- package/docs/hasAccessibleName.js.html +2 -10
- package/docs/hasAttribute.js.html +7 -3
- package/docs/hasCSSGeneratedContent.js.html +18 -14
- package/docs/hasHiddenParent.js.html +4 -4
- package/docs/hasParent.js.html +7 -3
- package/docs/hasValidAriaAttributes.js.html +7 -3
- package/docs/index.html +1 -1
- package/docs/index.js.html +98 -32
- package/docs/isA11yVisible.js.html +98 -0
- package/docs/isAriaAttributesValid.js.html +10 -64
- package/docs/isComplexTable.js.html +13 -6
- package/docs/isDataTable.js.html +11 -6
- package/docs/isFocusable.js.html +36 -12
- package/docs/isHidden.js.html +47 -11
- package/docs/isOffScreen.js.html +7 -3
- package/docs/isValidUrl.js.html +7 -3
- package/docs/listEventListeners.js.html +203 -0
- package/docs/module-QueryCache.html +3 -0
- package/docs/module-afixt-test-utils.html +1 -1
- package/docs/module-colorConversions.html +3 -0
- package/docs/module-constants.html +3 -0
- package/docs/module-cssUtils.html +3 -0
- package/docs/module-formUtils.html +3 -0
- package/docs/module-suggestContrast.html +3 -0
- package/docs/module-tableUtils.html +3 -0
- package/docs/queryCache.js.html +360 -0
- package/docs/scripts/core.js +726 -726
- package/docs/scripts/core.min.js +22 -22
- package/docs/scripts/resize.js +90 -90
- package/docs/scripts/search.js +265 -265
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -202
- package/docs/scripts/third-party/fuse.js +8 -8
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -369
- package/docs/scripts/third-party/hljs-original.js +5171 -5171
- package/docs/scripts/third-party/popper.js +5 -5
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +671 -671
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -1159
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -412
- package/docs/styles/clean-jsdoc-theme-light.css +482 -482
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +29 -29
- package/docs/suggestContrast.js.html +389 -0
- package/docs/tableUtils.js.html +151 -0
- package/docs/testContrast.js.html +201 -24
- package/docs/testLang.js.html +533 -451
- package/docs/testOrder.js.html +9 -4
- package/package.json +1 -1
- package/src/colorConversions.js +235 -0
- package/src/index.js +6 -0
- package/src/stringUtils.js +35 -0
- package/src/suggestContrast.js +386 -0
- package/test/colorConversions.test.js +223 -0
- package/test/stringUtils.test.js +60 -0
- package/test/suggestContrast.test.js +394 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
2
|
+
import { suggestContrast, computeContrastRatio } from '../src/suggestContrast.js';
|
|
3
|
+
|
|
4
|
+
describe('suggestContrast', () => {
|
|
5
|
+
// ---- Input validation ----
|
|
6
|
+
describe('input validation', () => {
|
|
7
|
+
it('should return empty array for null options', () => {
|
|
8
|
+
expect(suggestContrast(null)).toEqual([]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should return empty array for undefined options', () => {
|
|
12
|
+
expect(suggestContrast(undefined)).toEqual([]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should return empty array for non-object options', () => {
|
|
16
|
+
expect(suggestContrast('string')).toEqual([]);
|
|
17
|
+
expect(suggestContrast(42)).toEqual([]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should return empty array for missing foreground', () => {
|
|
21
|
+
expect(suggestContrast({ background: '#FFFFFF' })).toEqual([]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return empty array for missing background', () => {
|
|
25
|
+
expect(suggestContrast({ foreground: '#000000' })).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should return empty array for invalid foreground color', () => {
|
|
29
|
+
expect(suggestContrast({ foreground: 'not-a-color', background: '#FFFFFF' })).toEqual(
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return empty array for invalid background color', () => {
|
|
35
|
+
expect(suggestContrast({ foreground: '#000000', background: 'invalid' })).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return empty array for minRatio below 1', () => {
|
|
39
|
+
expect(
|
|
40
|
+
suggestContrast({ foreground: '#000000', background: '#FFFFFF', minRatio: 0.5 })
|
|
41
|
+
).toEqual([]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should return empty array for minRatio above 21', () => {
|
|
45
|
+
expect(
|
|
46
|
+
suggestContrast({ foreground: '#000000', background: '#FFFFFF', minRatio: 22 })
|
|
47
|
+
).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ---- Basic functionality ----
|
|
52
|
+
describe('basic functionality', () => {
|
|
53
|
+
it('should return an array', () => {
|
|
54
|
+
const result = suggestContrast({
|
|
55
|
+
foreground: '#777777',
|
|
56
|
+
background: '#FFFFFF',
|
|
57
|
+
minRatio: 4.5,
|
|
58
|
+
});
|
|
59
|
+
expect(Array.isArray(result)).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should return at most 12 suggestions', () => {
|
|
63
|
+
const result = suggestContrast({
|
|
64
|
+
foreground: '#777777',
|
|
65
|
+
background: '#FFFFFF',
|
|
66
|
+
minRatio: 4.5,
|
|
67
|
+
});
|
|
68
|
+
expect(result.length).toBeLessThanOrEqual(12);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should return at least 1 suggestion for a low-contrast pair', () => {
|
|
72
|
+
const result = suggestContrast({
|
|
73
|
+
foreground: '#777777',
|
|
74
|
+
background: '#FFFFFF',
|
|
75
|
+
minRatio: 4.5,
|
|
76
|
+
});
|
|
77
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// ---- Result structure ----
|
|
82
|
+
describe('result structure', () => {
|
|
83
|
+
let result;
|
|
84
|
+
|
|
85
|
+
beforeAll(() => {
|
|
86
|
+
result = suggestContrast({
|
|
87
|
+
foreground: '#999999',
|
|
88
|
+
background: '#FFFFFF',
|
|
89
|
+
minRatio: 4.5,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should have foreground with hex, rgb, and hsl properties', () => {
|
|
94
|
+
const suggestion = result[0];
|
|
95
|
+
expect(suggestion.foreground).toBeDefined();
|
|
96
|
+
expect(suggestion.foreground.hex).toBeDefined();
|
|
97
|
+
expect(suggestion.foreground.rgb).toBeDefined();
|
|
98
|
+
expect(suggestion.foreground.hsl).toBeDefined();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should have background with hex, rgb, and hsl properties', () => {
|
|
102
|
+
const suggestion = result[0];
|
|
103
|
+
expect(suggestion.background).toBeDefined();
|
|
104
|
+
expect(suggestion.background.hex).toBeDefined();
|
|
105
|
+
expect(suggestion.background.rgb).toBeDefined();
|
|
106
|
+
expect(suggestion.background.hsl).toBeDefined();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should have contrastRatio that meets the minimum', () => {
|
|
110
|
+
for (const suggestion of result) {
|
|
111
|
+
expect(suggestion.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should have a numeric distance property', () => {
|
|
116
|
+
for (const suggestion of result) {
|
|
117
|
+
expect(typeof suggestion.distance).toBe('number');
|
|
118
|
+
expect(suggestion.distance).toBeGreaterThanOrEqual(0);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should have valid hex values (7-character strings starting with #)', () => {
|
|
123
|
+
for (const suggestion of result) {
|
|
124
|
+
expect(suggestion.foreground.hex).toMatch(/^#[0-9a-f]{6}$/);
|
|
125
|
+
expect(suggestion.background.hex).toMatch(/^#[0-9a-f]{6}$/);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should have integer RGB values in 0-255 range', () => {
|
|
130
|
+
for (const suggestion of result) {
|
|
131
|
+
for (const color of [suggestion.foreground, suggestion.background]) {
|
|
132
|
+
expect(Number.isInteger(color.rgb.r)).toBe(true);
|
|
133
|
+
expect(Number.isInteger(color.rgb.g)).toBe(true);
|
|
134
|
+
expect(Number.isInteger(color.rgb.b)).toBe(true);
|
|
135
|
+
expect(color.rgb.r).toBeGreaterThanOrEqual(0);
|
|
136
|
+
expect(color.rgb.r).toBeLessThanOrEqual(255);
|
|
137
|
+
expect(color.rgb.g).toBeGreaterThanOrEqual(0);
|
|
138
|
+
expect(color.rgb.g).toBeLessThanOrEqual(255);
|
|
139
|
+
expect(color.rgb.b).toBeGreaterThanOrEqual(0);
|
|
140
|
+
expect(color.rgb.b).toBeLessThanOrEqual(255);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should have HSL h in 0-360, s in 0-100, l in 0-100', () => {
|
|
146
|
+
for (const suggestion of result) {
|
|
147
|
+
for (const color of [suggestion.foreground, suggestion.background]) {
|
|
148
|
+
expect(color.hsl.h).toBeGreaterThanOrEqual(0);
|
|
149
|
+
expect(color.hsl.h).toBeLessThanOrEqual(360);
|
|
150
|
+
expect(color.hsl.s).toBeGreaterThanOrEqual(0);
|
|
151
|
+
expect(color.hsl.s).toBeLessThanOrEqual(100);
|
|
152
|
+
expect(color.hsl.l).toBeGreaterThanOrEqual(0);
|
|
153
|
+
expect(color.hsl.l).toBeLessThanOrEqual(100);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ---- Contrast validity for specific pairs ----
|
|
160
|
+
describe('contrast validity', () => {
|
|
161
|
+
it('should produce valid suggestions for light gray on white', () => {
|
|
162
|
+
const result = suggestContrast({
|
|
163
|
+
foreground: '#CCCCCC',
|
|
164
|
+
background: '#FFFFFF',
|
|
165
|
+
minRatio: 4.5,
|
|
166
|
+
});
|
|
167
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
168
|
+
for (const s of result) {
|
|
169
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should produce valid suggestions for dark gray on black', () => {
|
|
174
|
+
const result = suggestContrast({
|
|
175
|
+
foreground: '#333333',
|
|
176
|
+
background: '#000000',
|
|
177
|
+
minRatio: 4.5,
|
|
178
|
+
});
|
|
179
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
180
|
+
for (const s of result) {
|
|
181
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('should produce valid suggestions for red on green', () => {
|
|
186
|
+
const result = suggestContrast({
|
|
187
|
+
foreground: '#FF0000',
|
|
188
|
+
background: '#00FF00',
|
|
189
|
+
minRatio: 4.5,
|
|
190
|
+
});
|
|
191
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
192
|
+
for (const s of result) {
|
|
193
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should produce suggestions even when pair already meets ratio', () => {
|
|
198
|
+
const result = suggestContrast({
|
|
199
|
+
foreground: '#000000',
|
|
200
|
+
background: '#FFFFFF',
|
|
201
|
+
minRatio: 4.5,
|
|
202
|
+
});
|
|
203
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
204
|
+
for (const s of result) {
|
|
205
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ---- Input format acceptance ----
|
|
211
|
+
describe('input format acceptance', () => {
|
|
212
|
+
it('should accept 6-digit hex colors', () => {
|
|
213
|
+
const result = suggestContrast({
|
|
214
|
+
foreground: '#FF0000',
|
|
215
|
+
background: '#FFFFFF',
|
|
216
|
+
minRatio: 4.5,
|
|
217
|
+
});
|
|
218
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('should accept 3-digit hex colors', () => {
|
|
222
|
+
const result = suggestContrast({
|
|
223
|
+
foreground: '#F00',
|
|
224
|
+
background: '#FFF',
|
|
225
|
+
minRatio: 4.5,
|
|
226
|
+
});
|
|
227
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should accept rgb() strings', () => {
|
|
231
|
+
const result = suggestContrast({
|
|
232
|
+
foreground: 'rgb(255, 0, 0)',
|
|
233
|
+
background: 'rgb(255, 255, 255)',
|
|
234
|
+
minRatio: 4.5,
|
|
235
|
+
});
|
|
236
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should accept hsl() strings', () => {
|
|
240
|
+
const result = suggestContrast({
|
|
241
|
+
foreground: 'hsl(0, 100%, 50%)',
|
|
242
|
+
background: 'hsl(0, 0%, 100%)',
|
|
243
|
+
minRatio: 4.5,
|
|
244
|
+
});
|
|
245
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// ---- Default minRatio behavior ----
|
|
250
|
+
describe('default minRatio', () => {
|
|
251
|
+
it('should default to 4.5 for normal text (fontSize < 18, not bold)', () => {
|
|
252
|
+
const result = suggestContrast({
|
|
253
|
+
foreground: '#999999',
|
|
254
|
+
background: '#FFFFFF',
|
|
255
|
+
fontSize: 14,
|
|
256
|
+
});
|
|
257
|
+
// All suggestions should meet 4.5 (the default for normal text)
|
|
258
|
+
for (const s of result) {
|
|
259
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('should default to 3.0 for large text (fontSize >= 18)', () => {
|
|
264
|
+
const result = suggestContrast({
|
|
265
|
+
foreground: '#999999',
|
|
266
|
+
background: '#FFFFFF',
|
|
267
|
+
fontSize: 18,
|
|
268
|
+
});
|
|
269
|
+
for (const s of result) {
|
|
270
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(3.0);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should default to 3.0 for bold text >= 14px', () => {
|
|
275
|
+
const result = suggestContrast({
|
|
276
|
+
foreground: '#999999',
|
|
277
|
+
background: '#FFFFFF',
|
|
278
|
+
fontSize: 14,
|
|
279
|
+
isBold: true,
|
|
280
|
+
});
|
|
281
|
+
for (const s of result) {
|
|
282
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(3.0);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// ---- Sorting and proximity ----
|
|
288
|
+
describe('sorting and proximity', () => {
|
|
289
|
+
it('should sort suggestions by distance (closest first)', () => {
|
|
290
|
+
const result = suggestContrast({
|
|
291
|
+
foreground: '#888888',
|
|
292
|
+
background: '#FFFFFF',
|
|
293
|
+
minRatio: 4.5,
|
|
294
|
+
});
|
|
295
|
+
if (result.length >= 2) {
|
|
296
|
+
for (let i = 1; i < result.length; i++) {
|
|
297
|
+
expect(result[i].distance).toBeGreaterThanOrEqual(result[i - 1].distance);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// ---- Edge cases ----
|
|
304
|
+
describe('edge cases', () => {
|
|
305
|
+
it('should handle identical foreground and background colors', () => {
|
|
306
|
+
const result = suggestContrast({
|
|
307
|
+
foreground: '#808080',
|
|
308
|
+
background: '#808080',
|
|
309
|
+
minRatio: 4.5,
|
|
310
|
+
});
|
|
311
|
+
expect(Array.isArray(result)).toBe(true);
|
|
312
|
+
for (const s of result) {
|
|
313
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(4.5);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('should return limited results for very high ratio requirement', () => {
|
|
318
|
+
const result = suggestContrast({
|
|
319
|
+
foreground: '#808080',
|
|
320
|
+
background: '#808080',
|
|
321
|
+
minRatio: 20,
|
|
322
|
+
});
|
|
323
|
+
// Very high ratio is hard to achieve, expect few or no results
|
|
324
|
+
expect(Array.isArray(result)).toBe(true);
|
|
325
|
+
for (const s of result) {
|
|
326
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(20);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should handle pure black on pure white', () => {
|
|
331
|
+
const result = suggestContrast({
|
|
332
|
+
foreground: '#000000',
|
|
333
|
+
background: '#FFFFFF',
|
|
334
|
+
minRatio: 7,
|
|
335
|
+
});
|
|
336
|
+
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
337
|
+
for (const s of result) {
|
|
338
|
+
expect(s.contrastRatio).toBeGreaterThanOrEqual(7);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// ---- Diversity of results ----
|
|
344
|
+
describe('diversity of results', () => {
|
|
345
|
+
it('should produce diverse suggestions (not all identical)', () => {
|
|
346
|
+
const result = suggestContrast({
|
|
347
|
+
foreground: '#888888',
|
|
348
|
+
background: '#FFFFFF',
|
|
349
|
+
minRatio: 4.5,
|
|
350
|
+
});
|
|
351
|
+
if (result.length >= 3) {
|
|
352
|
+
const uniquePairs = new Set(
|
|
353
|
+
result.map(s => s.foreground.hex + '|' + s.background.hex)
|
|
354
|
+
);
|
|
355
|
+
expect(uniquePairs.size).toBeGreaterThanOrEqual(3);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('should include both foreground-modified and background-modified suggestions', () => {
|
|
360
|
+
const result = suggestContrast({
|
|
361
|
+
foreground: '#888888',
|
|
362
|
+
background: '#FFFFFF',
|
|
363
|
+
minRatio: 4.5,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const hasFgModified = result.some(s => s.foreground.hex !== '#888888');
|
|
367
|
+
const hasBgModified = result.some(s => s.background.hex !== '#ffffff');
|
|
368
|
+
// At least one type of modification should be present
|
|
369
|
+
expect(hasFgModified || hasBgModified).toBe(true);
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// ---- computeContrastRatio ----
|
|
374
|
+
describe('computeContrastRatio', () => {
|
|
375
|
+
it('should return 21 for black on white', () => {
|
|
376
|
+
expect(computeContrastRatio({ r: 0, g: 0, b: 0 }, { r: 255, g: 255, b: 255 })).toBe(21);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('should return 1 for identical colors', () => {
|
|
380
|
+
expect(
|
|
381
|
+
computeContrastRatio({ r: 128, g: 128, b: 128 }, { r: 128, g: 128, b: 128 })
|
|
382
|
+
).toBe(1);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('should return a value between 1 and 21', () => {
|
|
386
|
+
const ratio = computeContrastRatio(
|
|
387
|
+
{ r: 100, g: 50, b: 200 },
|
|
388
|
+
{ r: 200, g: 200, b: 50 }
|
|
389
|
+
);
|
|
390
|
+
expect(ratio).toBeGreaterThanOrEqual(1);
|
|
391
|
+
expect(ratio).toBeLessThanOrEqual(21);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
});
|