This commit is contained in:
Tom Moor
2021-10-21 21:23:58 -07:00
parent 63c0daf483
commit c79a22b857
6 changed files with 18 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ import PlaceholderList from "components/List/Placeholder";
import { dateToHeading } from "utils/dates";
type Props = {
fetch?: (options: ?Object) => Promise<void>,
fetch?: (options: ?Object) => Promise<any>,
options?: Object,
heading?: React.Node,
empty?: React.Node,

View File

@@ -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}
/>
);

View File

@@ -112,7 +112,6 @@ function Collections({ onCreateCollection }: Props) {
<SidebarLink
label={t("Collections")}
icon={<Disclosure expanded={expanded} color="currentColor" />}
disabled
/>
<PlaceholderCollections />
</Flex>

View File

@@ -27,7 +27,7 @@ const joinClassnames = (...classnames) => {
return classnames.filter((i) => i).join(" ");
};
type Props = {|
export type Props = {|
activeClassName?: String,
activeStyle?: Object,
className?: string,

View File

@@ -4,15 +4,15 @@ import * as React from "react";
import styled, { useTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import EventBoundary from "components/EventBoundary";
import NavLink from "./NavLink";
import NavLink, { type Props as NavLinkProps } from "./NavLink";
type Props = {|
...NavLinkProps,
to?: string | Object,
href?: string | Object,
innerRef?: (?HTMLElement) => void,
onClick?: (SyntheticEvent<>) => void,
onClick?: (SyntheticEvent<>) => mixed,
onMouseEnter?: (SyntheticEvent<>) => void,
className?: string,
children?: React.Node,
icon?: React.Node,
label?: React.Node,
@@ -20,7 +20,6 @@ type Props = {|
showActions?: boolean,
active?: boolean,
isActiveDrop?: boolean,
exact?: boolean,
depth?: number,
scrollIntoViewIfNeeded?: boolean,
|};