flow
This commit is contained in:
@ -2,15 +2,21 @@
|
||||
import "../stores";
|
||||
import { shallow } from "enzyme";
|
||||
import * as React from "react";
|
||||
import AuthStore from "stores/AuthStore";
|
||||
import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore";
|
||||
import RootStore from "stores/RootStore";
|
||||
import { runAllPromises } from "../test/support";
|
||||
import { Component as PaginatedList } from "./PaginatedList";
|
||||
|
||||
describe("PaginatedList", () => {
|
||||
const render = () => null;
|
||||
const rootStore = new RootStore();
|
||||
const props = { auth: new AuthStore(rootStore), t: (string) => "test" };
|
||||
|
||||
it("with no items renders nothing", () => {
|
||||
const list = shallow(<PaginatedList items={[]} renderItem={render} />);
|
||||
const list = shallow(
|
||||
<PaginatedList items={[]} renderItem={render} {...props} />
|
||||
);
|
||||
expect(list).toEqual({});
|
||||
});
|
||||
|
||||
@ -20,6 +26,7 @@ describe("PaginatedList", () => {
|
||||
items={[]}
|
||||
empty={<p>Sorry, no results</p>}
|
||||
renderItem={render}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
expect(list.text()).toEqual("Sorry, no results");
|
||||
@ -35,6 +42,7 @@ describe("PaginatedList", () => {
|
||||
fetch={fetch}
|
||||
options={options}
|
||||
renderItem={render}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
expect(fetch).toHaveBeenCalledWith({
|
||||
@ -46,7 +54,7 @@ describe("PaginatedList", () => {
|
||||
|
||||
it("calls fetch when options prop changes", async () => {
|
||||
const fetchedItems = Array(DEFAULT_PAGINATION_LIMIT).fill();
|
||||
const fetch = jest.fn().mockReturnValue(fetchedItems);
|
||||
const fetch = jest.fn().mockReturnValue(Promise.resolve(fetchedItems));
|
||||
|
||||
const list = shallow(
|
||||
<PaginatedList
|
||||
@ -54,6 +62,7 @@ describe("PaginatedList", () => {
|
||||
fetch={fetch}
|
||||
options={{ id: "one" }}
|
||||
renderItem={render}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user