|
1 | 1 | import React from "react" |
2 | 2 | import Article from "../Article" |
3 | | -import Undernet from "undernet" |
4 | 3 | import Prism from "prismjs" |
| 4 | +import { COMPONENTS } from "../constants" |
5 | 5 |
|
6 | 6 | jest.mock("app/components/ScrollUpOnMount", () => global.simpleMock("ScrollUpOnMount")) |
7 | 7 |
|
8 | 8 | global.scrollTo = jest.fn() |
9 | 9 |
|
10 | | -const components = ["Tooltips", "Accordions", "Modals", "Dropdowns"] |
11 | | - |
12 | | -components.forEach(component => { |
13 | | - Undernet[component].start = jest.fn() |
14 | | - Undernet[component].stop = jest.fn() |
| 10 | +COMPONENTS.forEach(Component => { |
| 11 | + Component.start = jest.fn() |
| 12 | + Component.stop = jest.fn() |
15 | 13 | }) |
16 | 14 |
|
17 | 15 | jest.mock("prismjs", () => ({ |
@@ -52,25 +50,25 @@ describe("<Article />", () => { |
52 | 50 | expect(Prism.highlightAll).toHaveBeenCalled() |
53 | 51 | }) |
54 | 52 |
|
55 | | - components.forEach(component => { |
56 | | - it(`calls Undernet.${component}.start`, () => { |
| 53 | + COMPONENTS.forEach(Component => { |
| 54 | + it(`calls ${Component}.start`, () => { |
57 | 55 | // Given |
58 | 56 | mountComponent() |
59 | 57 | // Then |
60 | | - expect(Undernet[component].start).toHaveBeenCalled() |
| 58 | + expect(Component.start).toHaveBeenCalled() |
61 | 59 | }) |
62 | 60 | }) |
63 | 61 | }) |
64 | 62 |
|
65 | 63 | describe("#componentWillUnmount", () => { |
66 | | - components.forEach(component => { |
67 | | - it(`calls Undernet.${component}.stop`, () => { |
| 64 | + COMPONENTS.forEach(Component => { |
| 65 | + it(`calls ${Component}.stop`, () => { |
68 | 66 | // Given |
69 | 67 | const wrapper = mountComponent() |
70 | 68 | // When |
71 | 69 | wrapper.unmount() |
72 | 70 | // Then |
73 | | - expect(Undernet[component].stop).toHaveBeenCalled() |
| 71 | + expect(Component.stop).toHaveBeenCalled() |
74 | 72 | }) |
75 | 73 | }) |
76 | 74 | }) |
|
0 commit comments