mirror of
https://github.com/chakra-ui/chakra-ui.git
synced 2026-09-14 16:43:45 +08:00
7b5bdcc588
* refactor: color-mode utils and provider * fix: error when options is null * feat: support for cookie script * feat: support for custom managers * fix: scripts and provider * chore: update the next-js examples * refactor: color mode tests and manager * chore: refactor next-js example * chore: cleanup * chore: set correct precedence for color-mode and add color-scheme * docs: add changeset * chore: use explicit return Co-authored-by: Tim Kolberger <tim@kolberger.eu> * chore: use explicit return Co-authored-by: Tim Kolberger <tim@kolberger.eu> * test: update mocks in utils * test: add root match media mock * chore: cleanup * docs: update changeset * chore: update utils * test: update to match expectations * test: update to match expectations * chore: update color mode provider Co-authored-by: Tim Kolberger <tim@kolberger.eu>
22 lines
604 B
TypeScript
22 lines
604 B
TypeScript
//@ts-expect-error
|
|
const { getComputedStyle } = window
|
|
window.getComputedStyle = (elt) => getComputedStyle(elt)
|
|
|
|
if (typeof window.matchMedia !== "function") {
|
|
Object.defineProperty(window, "matchMedia", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(), // Deprecated
|
|
removeListener: jest.fn(), // Deprecated
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
})
|
|
}
|