(C: ClassC, afterMount?: Function, afterUnmount?: Function)
| 11 | } |
| 12 | |
| 13 | function testComponent(C: ClassC, afterMount?: Function, afterUnmount?: Function) { |
| 14 | const ref = React.createRef<ClassC>() |
| 15 | const { unmount } = render(<C ref={ref} />) |
| 16 | |
| 17 | let cref = ref.current |
| 18 | expect(cref?.methodA).not.toHaveBeenCalled() |
| 19 | expect(cref?.methodB).not.toHaveBeenCalled() |
| 20 | if (afterMount) { |
| 21 | afterMount(cref) |
| 22 | } |
| 23 | |
| 24 | unmount() |
| 25 | |
| 26 | expect(cref?.methodA).toHaveBeenCalledTimes(1) |
| 27 | expect(cref?.methodB).toHaveBeenCalledTimes(1) |
| 28 | if (afterUnmount) { |
| 29 | afterUnmount(cref) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | describe("without observer", () => { |
| 34 | test("class without componentWillUnmount", async () => { |
no test coverage detected
searching dependent graphs…