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