top-left-title-does-not-function-as-a-link
[arvados-workbench2.git] / src / views-components / main-app-bar / main-app-bar.test.tsx
index 030fb353e3d3e52f15dbfd22f478126a87b55807..69b4dd648cc86ea2b60fa2ebc8fb16173c1e6e29 100644 (file)
@@ -11,6 +11,7 @@ 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 { MemoryRouter } from 'react-router-dom';
 
 configure({ adapter: new Adapter() });
 
@@ -26,9 +27,11 @@ describe("<MainAppBar />", () => {
 
     it("renders all components and the menu for authenticated user if user prop has value", () => {
         const mainAppBar = mount(
-            <MainAppBar
-                {...mockMainAppBarProps({ user })}
-            />
+            <MemoryRouter>
+                <MainAppBar
+                    {...mockMainAppBarProps({ user })}
+                />
+            </MemoryRouter>
         );
         expect(mainAppBar.find(SearchBar)).toHaveLength(1);
         expect(mainAppBar.find(Breadcrumbs)).toHaveLength(1);
@@ -38,9 +41,11 @@ describe("<MainAppBar />", () => {
     it("renders only the menu for anonymous user if user prop is undefined", () => {
         const menuItems = { accountMenu: [], helpMenu: [], anonymousMenu: [{ label: 'Sign in' }] };
         const mainAppBar = mount(
-            <MainAppBar
-                {...mockMainAppBarProps({ user: undefined, menuItems })}
-            />
+            <MemoryRouter>
+                <MainAppBar
+                    {...mockMainAppBarProps({ user: undefined, menuItems })}
+                />
+            </MemoryRouter>
         );
         expect(mainAppBar.find(SearchBar)).toHaveLength(0);
         expect(mainAppBar.find(Breadcrumbs)).toHaveLength(0);
@@ -51,9 +56,11 @@ describe("<MainAppBar />", () => {
     it("communicates with <SearchBar />", () => {
         const onSearch = jest.fn();
         const mainAppBar = mount(
-            <MainAppBar
-                {...mockMainAppBarProps({ searchText: 'search text', searchDebounce: 2000, onSearch, user })}
-            />
+            <MemoryRouter>
+                <MainAppBar
+                    {...mockMainAppBarProps({ searchText: 'search text', searchDebounce: 2000, onSearch, user })}
+                />
+            </MemoryRouter>
         );
         const searchBar = mainAppBar.find(SearchBar);
         expect(searchBar.prop("value")).toBe("search text");
@@ -66,9 +73,11 @@ describe("<MainAppBar />", () => {
         const onMenuItemClick = jest.fn();
         const menuItems = { accountMenu: [{ label: "log out" }], helpMenu: [], anonymousMenu: [] };
         const mainAppBar = mount(
-            <MainAppBar
-                {...mockMainAppBarProps({ menuItems, onMenuItemClick, user })}
-            />
+            <MemoryRouter>
+                <MainAppBar
+                    {...mockMainAppBarProps({ menuItems, onMenuItemClick, user })}
+                />
+            </MemoryRouter>
         );
 
         mainAppBar.find(DropdownMenu).at(0).find(IconButton).simulate("click");