Skip to content

Commit

Permalink
Unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 9, 2021
1 parent 149231c commit 68e0ec8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ui/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import { NewProvider } from './metadata/new/NewProvider';
import { Filter } from './metadata/Filter';
import { Contention } from './metadata/contention/ContentionContext';
import { SessionModal } from './core/user/SessionModal';
import Button from 'react-bootstrap/esm/Button';
import Button from 'react-bootstrap/Button';


function App() {

const [showTimeout, setShowTimeout] = React.useState();
const [showTimeout] = React.useState();

const httpOptions = {
redirect: 'manual',
Expand Down
12 changes: 6 additions & 6 deletions ui/src/app/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import Translate from '../../../i18n/components/translate';
import { useTranslator } from '../../../i18n/hooks';
import { ChangeItem } from './ChangeItem';
import Alert from 'react-bootstrap/esm/Alert';
import Alert from 'react-bootstrap/Alert';

export function ContentionModal ({ theirs = [], ours = [], onUseTheirs, onUseOurs, ...props }) {

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/editor/MetadataEditorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FormCheck from 'react-bootstrap/FormCheck';
import { fields, widgets } from '../../form/component';
import { templates } from '../../form/component';
import { useUiSchema } from '../hooks/schema';
import Alert from 'react-bootstrap/esm/Alert';
import Alert from 'react-bootstrap/Alert';

const invisErrors = ['const', 'oneOf']

Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/metadata/wizard/MetadataSourceWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { removeNull } from '../../core/utility/remove_null';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import Translate from '../../i18n/components/translate';
import Alert from 'react-bootstrap/esm/Alert';
import Row from 'react-bootstrap/esm/Row';
import Col from 'react-bootstrap/esm/Col';
import Alert from 'react-bootstrap/Alert';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';

export function MetadataSourceWizard ({ onShowNav }) {

Expand Down
36 changes: 36 additions & 0 deletions ui/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,39 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
};
global.localStorage = localStorageMock;
/*
const documentCookieMock = {
cookies: '',
get cookie() {
return this.cookies;
},
set cookie(cookieValue) {
const cookies = this.cookies.split(' ');
const cookieName = cookieValue.split('=').shift();
const cookieNameLength = cookieName.length;
let cookieIndex = -1;
cookies.forEach((value, index) => {
if (`${value.substr(0, cookieNameLength)}=` === `${cookieName}=`) {
cookieIndex = index;
}
});
if (cookieIndex > -1) {
cookies[cookieIndex] = `${cookieValue};`;
} else {
cookies.push(`${cookieValue};`);
}
this.cookies = cookies.join(' ').trim();
},
};
global.document.cookie = documentCookieMock;*/

0 comments on commit 68e0ec8

Please sign in to comment.