-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathSettingsPanelCustomComponentSpec.ts
More file actions
52 lines (44 loc) · 1.63 KB
/
SettingsPanelCustomComponentSpec.ts
File metadata and controls
52 lines (44 loc) · 1.63 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
52
import { screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import Terria from "../../../lib/Models/Terria";
import ViewState from "../../../lib/ReactViewModels/ViewState";
import parseCustomMarkdownToReact from "../../../lib/ReactViews/Custom/parseCustomMarkdownToReact";
import registerCustomComponentTypes from "../../../lib/ReactViews/Custom/registerCustomComponentTypes";
import { renderWithContexts } from "../withContext";
import CustomComponent from "../../../lib/ReactViews/Custom/CustomComponent";
describe("SettingsPanelCustomComponent", function () {
let viewState: ViewState;
beforeEach(function () {
viewState = new ViewState({
terria: new Terria(),
catalogSearchProvider: undefined
});
registerCustomComponentTypes(viewState.terria);
});
afterEach(function () {
CustomComponent.unregisterAll();
});
it("renders", function () {
renderWithContexts(
parseCustomMarkdownToReact(
"Click to open <settingspanel title='Settings' />"
),
viewState
);
const settingsLink = screen.queryByTitle("Settings");
expect(settingsLink).toBeVisible();
});
it("opens the settings panel when clicked", async function () {
renderWithContexts(
parseCustomMarkdownToReact(
"Click to open <settingspanel title='Settings' />"
),
viewState
);
const settingsLink = screen.queryByTitle("Settings");
expect(settingsLink).toBeDefined();
expect(viewState.settingsPanelIsVisible).toBe(false);
await userEvent.click(settingsLink!);
expect(viewState.settingsPanelIsVisible).toBe(true);
});
});