diff --git a/src/components/common/WithAPIData.js b/src/components/common/WithAPIData.js index e658194..0376448 100644 --- a/src/components/common/WithAPIData.js +++ b/src/components/common/WithAPIData.js @@ -23,10 +23,12 @@ export class WithAPIData extends Component { ignoreCancel: PropTypes.bool, interval: PropTypes.number }), + /** * Render the children before the first API request is done */ renderInitial: PropTypes.func.isRequired, + /** * Render the children if the API request succeeded * @@ -34,6 +36,7 @@ export class WithAPIData extends Component { * @param refresh a function to trigger an asynchronous data refresh */ renderOk: PropTypes.func.isRequired, + /** * Render the children if the API request failed * diff --git a/src/components/dashboard/SummaryStats.test.js b/src/components/dashboard/SummaryStats.test.js index 40495c2..cea66fb 100644 --- a/src/components/dashboard/SummaryStats.test.js +++ b/src/components/dashboard/SummaryStats.test.js @@ -10,14 +10,12 @@ import React from "react"; import { shallow } from "enzyme"; -import fetchMock from "fetch-mock"; import { TranslatedSummaryStats, transformData, errorState } from "./SummaryStats"; -const endpoint = "/admin/api/stats/summary"; const fakeData = { domains_blocked: 10193, total_queries: 58787, @@ -32,8 +30,6 @@ const fakeData = { }; it("displays summary stats correctly", async () => { - fetchMock.mock(endpoint, fakeData); - const wrapper = shallow( ); @@ -55,9 +51,7 @@ it("displays summary stats correctly", async () => { ); }); -it("displays an error message on error", async () => { - fetchMock.mock(endpoint, { error: {} }); - +it("displays error message correctly", async () => { const wrapper = shallow(); await tick();