From 0f01fc5faa413dc83d7390ed15fc42e43472cee7 Mon Sep 17 00:00:00 2001
From: Tom Moor
Date: Fri, 2 Jul 2021 11:16:07 -0700
Subject: [PATCH] test: Reduce memory usage by not requiring stores into all
(#2265)
---
app/components/PaginatedList.test.js | 27 +++++++++++++++++++++++----
app/test/setup.js | 1 -
app/test/support.js | 2 +-
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/app/components/PaginatedList.test.js b/app/components/PaginatedList.test.js
index 831a45965..506c9c547 100644
--- a/app/components/PaginatedList.test.js
+++ b/app/components/PaginatedList.test.js
@@ -1,4 +1,5 @@
// @flow
+import "../stores";
import { shallow } from "enzyme";
import * as React from "react";
import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore";
@@ -6,14 +7,20 @@ import { runAllPromises } from "../test/support";
import PaginatedList from "./PaginatedList";
describe("PaginatedList", () => {
+ const render = () => null;
+
it("with no items renders nothing", () => {
- const list = shallow();
+ const list = shallow();
expect(list).toEqual({});
});
it("with no items renders empty prop", () => {
const list = shallow(
- Sorry, no results
} />
+ Sorry, no results}
+ renderItem={render}
+ />
);
expect(list.text()).toEqual("Sorry, no results");
});
@@ -22,7 +29,14 @@ describe("PaginatedList", () => {
const fetch = jest.fn();
const options = { id: "one" };
- shallow();
+ shallow(
+
+ );
expect(fetch).toHaveBeenCalledWith({
...options,
limit: DEFAULT_PAGINATION_LIMIT,
@@ -35,7 +49,12 @@ describe("PaginatedList", () => {
const fetch = jest.fn().mockReturnValue(fetchedItems);
const list = shallow(
-
+
);
await runAllPromises();
diff --git a/app/test/setup.js b/app/test/setup.js
index 92e2714e6..5e49a92f3 100644
--- a/app/test/setup.js
+++ b/app/test/setup.js
@@ -3,7 +3,6 @@
import localStorage from '../../__mocks__/localStorage';
import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";
-import "../stores";
Enzyme.configure({ adapter: new Adapter() });
diff --git a/app/test/support.js b/app/test/support.js
index f4f1c3fc3..3a8df2611 100644
--- a/app/test/support.js
+++ b/app/test/support.js
@@ -1,2 +1,2 @@
// @flow
-export const runAllPromises = () => new Promise(setImmediate);
+export const runAllPromises = () => new Promise(setImmediate);