diff --git a/ui/src/Components/Fetcher/index.test.js b/ui/src/Components/Fetcher/index.test.js
index 0b1b1d3c7..9edf28173 100644
--- a/ui/src/Components/Fetcher/index.test.js
+++ b/ui/src/Components/Fetcher/index.test.js
@@ -260,17 +260,18 @@ describe("", () => {
expect(fetchSpy).toHaveBeenCalledWith("", true, "", "", "");
});
- it("internal timer is armed after render", () => {
- const tree = MountedFetcher();
- const instance = tree.instance();
- expect(instance.timer).toBeGreaterThanOrEqual(0);
- });
-
it("internal timer is null after unmount", () => {
const tree = MountedFetcher();
- const instance = tree.instance();
- instance.componentWillUnmount();
- expect(instance.timer).toBeNull();
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
+
+ tree.unmount();
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
+
+ settingsStore.gridConfig.config.reverseSort = !settingsStore.gridConfig
+ .config.reverseSort;
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
+ jest.runOnlyPendingTimers();
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
});
it("doesn't fetch on mount when paused", () => {
@@ -281,16 +282,18 @@ describe("", () => {
it("doesn't fetch on update when paused", () => {
alertStore.status.pause();
- const tree = MountedFetcher();
- tree.instance().componentDidUpdate();
+ MountedFetcher();
+ settingsStore.gridConfig.config.reverseSort = !settingsStore.gridConfig
+ .config.reverseSort;
expect(fetchSpy).toHaveBeenCalledTimes(0);
});
it("fetches on update when resumed", () => {
alertStore.status.pause();
- const tree = MountedFetcher();
+ MountedFetcher();
alertStore.status.resume();
- tree.instance().componentDidUpdate();
+ settingsStore.gridConfig.config.reverseSort = !settingsStore.gridConfig
+ .config.reverseSort;
expect(fetchSpy).toHaveBeenCalledTimes(1);
});
diff --git a/ui/src/Components/Grid/ReloadNeeded/index.test.js b/ui/src/Components/Grid/ReloadNeeded/index.test.js
index 3866a35f2..61deee929 100644
--- a/ui/src/Components/Grid/ReloadNeeded/index.test.js
+++ b/ui/src/Components/Grid/ReloadNeeded/index.test.js
@@ -35,11 +35,9 @@ describe("", () => {
expect(reloadSpy).toBeCalled();
});
- it("timer is cleared on unmount", () => {
+ it("unmounts cleanly", () => {
const tree = mount();
- const instance = tree.instance();
-
- instance.componentWillUnmount();
- expect(instance.timer).toBeNull();
+ tree.unmount();
+ jest.runOnlyPendingTimers();
});
});
diff --git a/ui/src/Components/Modal/index.test.js b/ui/src/Components/Modal/index.test.js
index 5b83da167..e7a560848 100644
--- a/ui/src/Components/Modal/index.test.js
+++ b/ui/src/Components/Modal/index.test.js
@@ -40,7 +40,8 @@ describe("", () => {
document.body.classList.toggle("modal-open", true);
const tree = MountedModal(false);
expect(document.body.className.split(" ")).toContain("modal-open");
- tree.instance().componentDidUpdate();
+ // force update
+ tree.setProps({ style: {} });
expect(document.body.className.split(" ")).toContain("modal-open");
});
@@ -51,7 +52,8 @@ describe("", () => {
expect(document.body.className.split(" ")).toContain("modal-open");
isOpen = false;
- tree.instance().componentDidUpdate();
+ // force update
+ tree.setProps({ style: {} });
expect(document.body.className.split(" ")).toContain("modal-open");
});