[arvados-workbench2] updated: 2.4.0-356-g62e6fff9
git repository hosting
git at public.arvados.org
Wed Nov 16 19:48:02 UTC 2022
Summary of changes:
src/components/breadcrumbs/breadcrumbs.test.tsx | 52 +++++++++++++++++++------
1 file changed, 41 insertions(+), 11 deletions(-)
via 62e6fff927ed9def5dc9cecb9a67b0fee7430e5d (commit)
from 2fc84a5c44d769d5ef4e450dcddf2e5083a30b6a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 62e6fff927ed9def5dc9cecb9a67b0fee7430e5d
Author: Stephen Smith <stephen at curii.com>
Date: Wed Nov 16 14:47:50 2022 -0500
19504: Fix breadcrumb unit tests
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>
diff --git a/src/components/breadcrumbs/breadcrumbs.test.tsx b/src/components/breadcrumbs/breadcrumbs.test.tsx
index 1594c036..f17ce393 100644
--- a/src/components/breadcrumbs/breadcrumbs.test.tsx
+++ b/src/components/breadcrumbs/breadcrumbs.test.tsx
@@ -3,12 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0
import React from "react";
-import { configure, shallow } from "enzyme";
+import { configure, mount } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import { Breadcrumbs } from "./breadcrumbs";
-import { Button } from "@material-ui/core";
+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() });
@@ -16,36 +19,63 @@ describe("<Breadcrumbs />", () => {
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 = shallow(<Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />).dive();
+ const breadcrumbs = mount(
+ <Provider store={store}>
+ <MuiThemeProvider theme={CustomTheme}>
+ <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />
+ </MuiThemeProvider>
+ </Provider>);
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 = shallow(<Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />).dive();
+ const breadcrumbs = mount(
+ <Provider store={store}>
+ <MuiThemeProvider theme={CustomTheme}>
+ <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />
+ </MuiThemeProvider>
+ </Provider>);
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 = shallow(<Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />).dive();
+ const breadcrumbs = mount(
+ <Provider store={store}>
+ <MuiThemeProvider theme={CustomTheme}>
+ <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={jest.fn()} />
+ </MuiThemeProvider>
+ </Provider>);
breadcrumbs.find(Button).at(1).simulate('click');
expect(onClick).toBeCalledWith(items[1]);
});
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list