X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/065f393316fad3472ab2afe526c7965be1fe392d..21d7f6cb32902073193db810b4dfad85d9cdff7e:/src/components/breadcrumbs/breadcrumbs.test.tsx diff --git a/src/components/breadcrumbs/breadcrumbs.test.tsx b/src/components/breadcrumbs/breadcrumbs.test.tsx index 77beb494..f17ce393 100644 --- a/src/components/breadcrumbs/breadcrumbs.test.tsx +++ b/src/components/breadcrumbs/breadcrumbs.test.tsx @@ -2,52 +2,82 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from "react"; -import { mount, configure } from "enzyme"; +import React from "react"; +import { configure, mount } from "enzyme"; -import * as Adapter from "enzyme-adapter-react-16"; -import Breadcrumbs from "./breadcrumbs"; -import { Button } from "@material-ui/core"; +import Adapter from "enzyme-adapter-react-16"; +import { Breadcrumbs } from "./breadcrumbs"; +import { Button, MuiThemeProvider } from "@material-ui/core"; import ChevronRightIcon from '@material-ui/icons/ChevronRight'; +import { CustomTheme } from 'common/custom-theme'; +import { Provider } from "react-redux"; +import { combineReducers, createStore } from "redux"; configure({ adapter: new Adapter() }); describe("", () => { let onClick: () => void; - + let resources = {}; + let store; beforeEach(() => { onClick = jest.fn(); + const initialAuthState = { + config: { + clusterConfig: { + Collections: { + ForwardSlashNameSubstitution: "/" + } + } + } + } + store = createStore(combineReducers({ + auth: (state: any = initialAuthState, action: any) => state, + })); }); it("renders one item", () => { const items = [ - {label: 'breadcrumb 1'} + { label: 'breadcrumb 1', uuid: '1' } ]; - const breadcrumbs = mount(); + const breadcrumbs = mount( + + + + + ); expect(breadcrumbs.find(Button)).toHaveLength(1); expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(0); }); - + it("renders multiple items", () => { const items = [ - {label: 'breadcrumb 1'}, - {label: 'breadcrumb 2'} + { label: 'breadcrumb 1', uuid: '1' }, + { label: 'breadcrumb 2', uuid: '2' } ]; - const breadcrumbs = mount(); + const breadcrumbs = mount( + + + + + ); expect(breadcrumbs.find(Button)).toHaveLength(2); expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(1); }); - + it("calls onClick with clicked item", () => { const items = [ - {label: 'breadcrumb 1'}, - {label: 'breadcrumb 2'} + { label: 'breadcrumb 1', uuid: '1' }, + { label: 'breadcrumb 2', uuid: '2' } ]; - const breadcrumbs = mount(); + const breadcrumbs = mount( + + + + + ); breadcrumbs.find(Button).at(1).simulate('click'); expect(onClick).toBeCalledWith(items[1]); }); - -}); \ No newline at end of file +});