1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { Breadcrumbs } from "./breadcrumbs";
7 import { ThemeProvider, StyledEngineProvider } from "@mui/material";
8 import { CustomTheme } from 'common/custom-theme';
9 import { Provider } from "react-redux";
10 import { combineReducers, createStore } from "redux";
12 describe("<Breadcrumbs />", () => {
18 onClick = cy.spy().as('onClick');
19 const initialAuthState = {
23 ForwardSlashNameSubstitution: "/"
28 store = createStore(combineReducers({
29 auth: (state = initialAuthState, action) => state,
33 it("renders one item", () => {
35 { label: 'breadcrumb 1', uuid: '1' }
38 <Provider store={store}>
39 <StyledEngineProvider injectFirst>
40 <ThemeProvider theme={CustomTheme}>
41 <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={cy.stub()} />
43 </StyledEngineProvider>
45 cy.get('button').should('have.length', 1);
46 cy.get('button').should('have.text', 'breadcrumb 1');
47 cy.get('[data-testid=ChevronRightIcon]').should('have.length', 0);
50 it("renders multiple items", () => {
52 { label: 'breadcrumb 1', uuid: '1' },
53 { label: 'breadcrumb 2', uuid: '2' }
56 <Provider store={store}>
57 <StyledEngineProvider injectFirst>
58 <ThemeProvider theme={CustomTheme}>
59 <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={cy.stub()} />
61 </StyledEngineProvider>
63 cy.get('button').should('have.length', 2);
64 cy.get('[data-testid=ChevronRightIcon]').should('have.length', 1);
67 it("calls onClick with clicked item", () => {
69 { label: 'breadcrumb 1', uuid: '1' },
70 { label: 'breadcrumb 2', uuid: '2' }
73 <Provider store={store}>
74 <StyledEngineProvider injectFirst>
75 <ThemeProvider theme={CustomTheme}>
76 <Breadcrumbs items={items} resources={resources} onClick={onClick} onContextMenu={cy.stub()} />
78 </StyledEngineProvider>
80 cy.get('button').eq(1).click();
81 cy.get('@onClick').should('have.been.calledWith', Cypress.sinon.match.func, items[1]);