1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { mount, configure } from 'enzyme';
7 import Adapter from "enzyme-adapter-react-16";
8 import { StyledComponentProps, MuiThemeProvider } from '@material-ui/core';
9 import { ClusterConfigJSON } from 'common/config';
10 import { CustomTheme } from 'common/custom-theme';
11 import { NotFoundPanelRoot, NotFoundPanelRootDataProps, CssRules } from './not-found-panel-root';
13 configure({ adapter: new Adapter() });
15 describe('NotFoundPanelRoot', () => {
16 let props: NotFoundPanelRootDataProps & StyledComponentProps<CssRules>;
27 SupportEmailAddress: 'support@example.com'
29 } as ClusterConfigJSON,
34 it('should render component', () => {
36 const expectedMessage = "The page you requested was not found";
39 const wrapper = mount(
40 <MuiThemeProvider theme={CustomTheme}>
41 <NotFoundPanelRoot {...props} />
46 expect(wrapper.find('p').text()).toContain(expectedMessage);
49 it('should render component without email url when no email', () => {
51 props.clusterConfig.Users.SupportEmailAddress = '';
54 const wrapper = mount(
55 <MuiThemeProvider theme={CustomTheme}>
56 <NotFoundPanelRoot {...props} />
61 expect(wrapper.find('a').length).toBe(0);
64 it('should render component with additional message and email url', () => {
66 const hash = '123hash123';
67 const pathname = `/collections/${hash}`;
75 const wrapper = mount(
76 <MuiThemeProvider theme={CustomTheme}>
77 <NotFoundPanelRoot {...props} />
82 expect(wrapper.find('p').first().text()).toContain(hash);
85 expect(wrapper.find('a').length).toBe(1);