Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 17, 2022
1 parent 859cbb7 commit 6f5b2da
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 204 deletions.
1 change: 1 addition & 0 deletions ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ node {
}

npmInstall.setNpmCommand('ci')
npmInstall.args = ['--legacy-peer-deps']

npm_run_build {
inputs.dir 'src'
Expand Down
124 changes: 42 additions & 82 deletions ui/package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ui/src/app/admin/hoc/RolesProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ jest.mock('../hooks');

jest.mock('../../store/notifications/NotificationSlice');

const mockDispatch = jest.fn();
jest.mock('react-redux', () => ({
useSelector: jest.fn(),
useDispatch: () => mockDispatch
}));


describe('RolesProvider component', () => {

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Link, useHistory, useParams } from 'react-router-dom';

import Translate from '../../i18n/components/translate';
import FormattedDate from '../../core/components/FormattedDate';
import Button from 'react-bootstrap/esm/Button';
import Button from 'react-bootstrap/Button';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEdit, faHistory, faToggleOff, faToggleOn, faTrash } from '@fortawesome/free-solid-svg-icons';
import Badge from 'react-bootstrap/esm/Badge';
import { faToggleOff, faToggleOn, faTrash } from '@fortawesome/free-solid-svg-icons';
import Badge from 'react-bootstrap/Badge';
import { Configuration } from '../../metadata/hoc/Configuration';
import { MetadataConfiguration } from '../../metadata/component/MetadataConfiguration';

Expand All @@ -27,7 +27,7 @@ export function DynamicRegistrationDetail () {

const edit = (section) => {
history.push(`/dynamic-registration/${id}/edit`);
}
};

return (
<div className="container-fluid p-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ export const SourceBase = {
if (formData.assertionConsumerServices && formData.assertionConsumerServices.length) {
const { updated, added } = detailedDiff(original.assertionConsumerServices, formData.assertionConsumerServices);
const merged = merge(updated, added);
const changingDefault = Object.keys(merged).some(k => merged[k].hasOwnProperty('makeDefault'));
const changingDefault = Object.keys(merged).some(k => {
const obj = { ...merged[k] };
return obj.hasOwnProperty('makeDefault');
});



if (changingDefault) {
const settingToTrue = Object.keys(merged).some(k => merged[k].makeDefault === true);
if (settingToTrue) {
Expand Down
15 changes: 10 additions & 5 deletions ui/src/app/notifications/component/NotificationList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ import React from 'react';
import { render, screen } from '@testing-library/react';

import { NotificationList } from './NotificationList';
import { NotificationContext } from '../hoc/Notifications';

const mockDispatch = jest.fn();
jest.mock('react-redux', () => ({
useSelector: jest.fn(),
useDispatch: () => mockDispatch
}));

jest.mock('../../i18n/hooks', () => ({
useTranslation: (value) => value
}));

jest.mock('../../store/notifications/NotificationSlice', () => ({
useNotifications: () => [{id: 'foo', body: 'foo', type: 'danger'}]
}));

describe('Notification List', () => {
it('should render notifications', () => {
const dispatch = jest.fn();
const state = { notifications: [{id: 'foo', body: 'foo', type: 'danger'}] };
render(
<NotificationContext.Provider value={{ state, dispatch }}>
<NotificationList />
</NotificationContext.Provider>
);

expect(screen.getByText('foo')).toBeInTheDocument();
Expand Down
88 changes: 0 additions & 88 deletions ui/src/app/notifications/hoc/Notifications.js

This file was deleted.

24 changes: 0 additions & 24 deletions ui/src/app/notifications/hoc/Notifications.test.js

This file was deleted.

0 comments on commit 6f5b2da

Please sign in to comment.