-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathsetupTests.js
More file actions
44 lines (35 loc) · 1.09 KB
/
setupTests.js
File metadata and controls
44 lines (35 loc) · 1.09 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
import '@testing-library/jest-dom';
import { server } from './mocks/server';
class ResizeObserver {
disconnect() {}
observe() {}
unobserve() {}
}
window.ResizeObserver = ResizeObserver;
Element.prototype.scrollIntoView = jest.fn();
jest.mock('@ably/ui/core/utils/syntax-highlighter', () => ({
highlightSnippet: jest.fn,
LINE_HIGHLIGHT_CLASSES: {
addition: 'code-line-addition',
removal: 'code-line-removal',
highlight: 'code-line-highlight',
},
parseLineHighlights: (lang) => ({ lang, highlights: {} }),
registerDefaultLanguages: jest.fn,
splitHtmlLines: (html) => html.split('\n'),
}));
jest.mock('@ably/ui/core/Code', () => ({
__esModule: true,
default: () => null,
}));
jest.mock('@ably/ui/core/utils/syntax-highlighter-registry', () => ({
__esModule: true,
default: [],
}));
// Establish API mocking before all tests.
beforeAll(() => server.listen());
// Reset any request handlers that we may add during the tests,
// so they don't affect other tests.
afterEach(() => server.resetHandlers());
// Clean up after the tests are finished.
afterAll(() => server.close());