forked from DTStack/molecule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmolecule.test.tsx
67 lines (59 loc) · 1.97 KB
/
molecule.test.tsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import renderer from 'react-test-renderer';
import { select } from 'mo/common/dom';
import molecule, { MoleculeProvider, Workbench } from 'mo';
import { customExtensions } from '../../../stories/extensions';
describe('Test MoleculeProvider', () => {
beforeEach(() => {
// Reset the extensions loaded state
molecule.extension.setLoaded(false);
});
test('Match The MoleculeProvider snapshot', () => {
const component = renderer.create(
<MoleculeProvider>
<Workbench />
</MoleculeProvider>
);
expect(component.toJSON()).toMatchSnapshot();
});
test('MoleculeProvider should render built-in Workbench extensions', () => {
render(
<MoleculeProvider>
<Workbench />
</MoleculeProvider>
);
expect(
select('div[data-id="sidebar.explore.title"]')
).toBeInTheDocument();
expect(
select('div[data-id="sidebar.search.title"]')
).toBeInTheDocument();
expect(select('.mo-welcome')).toBeInTheDocument();
expect(
select('div[id="statusbar.problems.title"]')
).toBeInTheDocument();
});
test('MoleculeProvider load the extensions', async () => {
render(
<MoleculeProvider extensions={customExtensions}>
<Workbench />
</MoleculeProvider>
);
await expect(
select('div[data-id="ActivityBarTestPane"]')
).toBeInTheDocument();
});
test('MoleculeProvider load the locale language extensions', () => {
localStorage.removeItem('mo.localeId');
render(
<MoleculeProvider
extensions={customExtensions}
defaultLocale="zh-CN"
>
<Workbench />
</MoleculeProvider>
);
});
});