forked from pokeclicker/pokeclicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvitest.setup.js
29 lines (27 loc) · 890 Bytes
/
vitest.setup.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
import { vi } from 'vitest';
import * as ko from 'knockout';
const mockJQuery = vi.fn();
mockJQuery.mockImplementation(() => mockJQuery);
Object.assign(mockJQuery, {
ready: mockJQuery,
});
window.ko = ko;
window.$ = mockJQuery;
// would need a newer jsdom version to support this
window.CSS = {
supports: (...args) => {
if (args.length === 2) {
const [propertyName, value] = args;
// 'color' property
// Limited implementation only covering currently-needed values
if (propertyName === 'color') {
// Matches three-, four-, six-, and eight-value hex colors
const hexCodeRegex = /^#(?:[0-9a-fA-F]{3,4}){1,2}$/;
if (hexCodeRegex.test(value) || value === 'transparent') {
return true;
}
}
}
return false;
},
}