-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathApp.test.tsx
More file actions
51 lines (44 loc) · 1.4 KB
/
Copy pathApp.test.tsx
File metadata and controls
51 lines (44 loc) · 1.4 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: MIT
// Copyright (c) 2021-2026 The Pybricks Authors
import { cleanup } from '@testing-library/react';
import React from 'react';
import { testRender } from '../../test';
import App from './App';
jest.mock('react', () => {
const React = jest.requireActual('react');
// don't lazy-load, just use fallback for React.Suspense
React.Suspense = ({ fallback }: Record<string, unknown>) => fallback;
return React;
});
beforeAll(() => {
// this lets us use jest.spyOn with window.innerWidth
const defaultInnerWidth = window.innerWidth;
Object.defineProperty(window, 'innerWidth', {
get: () => defaultInnerWidth,
});
});
beforeEach(() => {
// prevent tour popup
localStorage.setItem('tour.showOnStartup', 'false');
});
afterEach(() => {
cleanup();
jest.resetAllMocks();
localStorage.clear();
sessionStorage.clear();
});
it.each([false, true])('should render', (darkMode) => {
localStorage.setItem(
'usehooks-ts-ternary-dark-mode',
JSON.stringify(darkMode ? 'dark' : 'light'),
);
testRender(<App />);
});
describe('documentation pane', () => {
it('should be collapsed by default', () => {
testRender(<App />);
// The docs panel starts collapsed (collapsedSize="0%")
const docsPanel = document.querySelector('[data-panel][id="docs"]');
expect(docsPanel).not.toBeNull();
});
});