33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
|
|
// Polyfill CSS.supports for jsdom (Seed's TextField uses @seed-design/react-supports,
|
|
// which calls CSS.supports; jsdom provides no CSS global). Assume support so the
|
|
// component renders; jsdom doesn't apply the styles either way.
|
|
if (typeof CSS === "undefined") {
|
|
(global as any).CSS = { supports: () => true };
|
|
} else if (typeof (CSS as any).supports !== "function") {
|
|
(CSS as any).supports = () => true;
|
|
}
|
|
|
|
// Polyfill localStorage for jsdom if not available
|
|
if (typeof localStorage === "undefined") {
|
|
const store: Record<string, string> = {};
|
|
(global as any).localStorage = {
|
|
getItem: (key: string) => store[key] || null,
|
|
setItem: (key: string, value: string) => {
|
|
store[key] = String(value);
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete store[key];
|
|
},
|
|
clear: () => {
|
|
for (const key in store) {
|
|
delete store[key];
|
|
}
|
|
},
|
|
key: (index: number) => Object.keys(store)[index] || null,
|
|
get length() {
|
|
return Object.keys(store).length;
|
|
},
|
|
};
|
|
}
|