Skip to content

Commit 57bb43b

Browse files
authored
Basic unit testing for frontend /webview-ui (RooCodeInc#1522)
* feat: very basic unit testing * move dep -> devDeps * correct other deps * resync after i18n revert on main * update package-lock.json
1 parent 3b5d39a commit 57bb43b

File tree

7 files changed

+2110
-450
lines changed

7 files changed

+2110
-450
lines changed

webview-ui/matchMedia.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// "Official" jest workaround for mocking window.matchMedia()
2+
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
3+
4+
Object.defineProperty(window, "matchMedia", {
5+
writable: true,
6+
value: vi.fn().mockImplementation((query) => ({
7+
matches: false,
8+
media: query,
9+
onchange: null,
10+
addListener: vi.fn(), // Deprecated
11+
removeListener: vi.fn(), // Deprecated
12+
addEventListener: vi.fn(),
13+
removeEventListener: vi.fn(),
14+
dispatchEvent: vi.fn(),
15+
})),
16+
})

0 commit comments

Comments
 (0)