X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e5b901f7d6f87b56f43d3dbe002c9c90a3d41349..fd866f7342773ce01af4eae68cc41a978786acff:/src/views-components/main-app-bar/main-app-bar.test.tsx diff --git a/src/views-components/main-app-bar/main-app-bar.test.tsx b/src/views-components/main-app-bar/main-app-bar.test.tsx index 25494b65a0..030fb353e3 100644 --- a/src/views-components/main-app-bar/main-app-bar.test.tsx +++ b/src/views-components/main-app-bar/main-app-bar.test.tsx @@ -3,14 +3,14 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from "react"; -import { mount, configure, ReactWrapper } from "enzyme"; +import { mount, configure } from "enzyme"; import * as Adapter from "enzyme-adapter-react-16"; -import MainAppBar from "./main-app-bar"; -import SearchBar from "../../components/search-bar/search-bar"; -import Breadcrumbs from "../../components/breadcrumbs/breadcrumbs"; -import DropdownMenu from "../../components/dropdown-menu/dropdown-menu"; +import { MainAppBar, MainAppBarProps } from './main-app-bar'; +import { SearchBar } from "~/components/search-bar/search-bar"; +import { Breadcrumbs } from "~/components/breadcrumbs/breadcrumbs"; +import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu"; import { Button, MenuItem, IconButton } from "@material-ui/core"; -import { User } from "../../models/user"; +import { User } from "~/models/user"; configure({ adapter: new Adapter() }); @@ -27,8 +27,7 @@ describe("", () => { it("renders all components and the menu for authenticated user if user prop has value", () => { const mainAppBar = mount( ); expect(mainAppBar.find(SearchBar)).toHaveLength(1); @@ -40,8 +39,7 @@ describe("", () => { const menuItems = { accountMenu: [], helpMenu: [], anonymousMenu: [{ label: 'Sign in' }] }; const mainAppBar = mount( ); expect(mainAppBar.find(SearchBar)).toHaveLength(0); @@ -54,10 +52,7 @@ describe("", () => { const onSearch = jest.fn(); const mainAppBar = mount( ); const searchBar = mainAppBar.find(SearchBar); @@ -67,30 +62,12 @@ describe("", () => { expect(onSearch).toBeCalledWith("new search text"); }); - it("communicates with ", () => { - const items = [{ label: "breadcrumb 1" }]; - const onBreadcrumbClick = jest.fn(); - const mainAppBar = mount( - - ); - const breadcrumbs = mainAppBar.find(Breadcrumbs); - expect(breadcrumbs.prop("items")).toBe(items); - breadcrumbs.prop("onClick")(items[0]); - expect(onBreadcrumbClick).toBeCalledWith(items[0]); - }); - it("communicates with menu", () => { const onMenuItemClick = jest.fn(); - const menuItems = { accountMenu: [{label: "log out"}], helpMenu: [], anonymousMenu: [] }; + const menuItems = { accountMenu: [{ label: "log out" }], helpMenu: [], anonymousMenu: [] }; const mainAppBar = mount( ); @@ -99,3 +76,20 @@ describe("", () => { expect(onMenuItemClick).toBeCalledWith(menuItems.accountMenu[0]); }); }); + +const Breadcrumbs = () => Breadcrumbs; + +const mockMainAppBarProps = (props: Partial): MainAppBarProps => ({ + searchText: '', + breadcrumbs: Breadcrumbs, + menuItems: { + accountMenu: [], + helpMenu: [], + anonymousMenu: [], + }, + buildInfo: '', + onSearch: jest.fn(), + onMenuItemClick: jest.fn(), + onDetailsPanelToggle: jest.fn(), + ...props, +});