Skip to content

Commit

Permalink
Merge branch 'master' into test-SSOLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke authored Dec 6, 2024
2 parents 490c05b + 85a6b57 commit 094fd2f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
16 changes: 16 additions & 0 deletions src/components/BadRequestScreen/BadRequestScreen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { render, screen } from '@folio/jest-config-stripes/testing-library/react';

import BadRequestScreen from './BadRequestScreen';

jest.mock('../../Pluggable', () => (props) => props.children);

describe('BadRequestScreen', () => {
it('renders expected message', () => {
render(<BadRequestScreen />);

screen.getByText('stripes-core.front.error.header');
screen.getByText(/stripes-core.front.error.general.message/);
});
});


20 changes: 11 additions & 9 deletions src/components/IfInterface/IfInterface.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { StripesContext } from '../../StripesContext';
import { useStripes } from '../../StripesContext';

const IfInterface = ({ children, name, version }) => (
<StripesContext.Consumer>
{stripes => (
stripes.hasInterface(name, version) ? children : null
)}
</StripesContext.Consumer>
);
const IfInterface = ({ children, name, version }) => {
const stripes = useStripes();
const hasInterface = stripes.hasInterface(name, version);

if (typeof children === 'function') {
return children({ hasInterface });
}

return hasInterface ? children : null;
};

IfInterface.propTypes = {
children: PropTypes.node,
Expand Down
33 changes: 33 additions & 0 deletions src/components/IfInterface/IfInterface.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { render, screen } from '@folio/jest-config-stripes/testing-library/react';

import { useStripes } from '../../StripesContext';
import Stripes from '../../Stripes';
import IfInterface from './IfInterface';

jest.mock('../../StripesContext');
const stripes = new Stripes({
discovery: {
interfaces: {
foo: '1.0'
}
},
logger: {
log: jest.fn(),
}
});

// IfInterface is just a component version of Stripes::hasInterface
// See more extensive tests there.
describe('IfInterface', () => {
it('returns true if interface is present', () => {
useStripes.mockReturnValue(stripes);
render(<IfInterface name="foo">monkey</IfInterface>);
expect(screen.queryByText(/monkey/)).toBeTruthy();
});

it('returns false if interface is absent', () => {
useStripes.mockReturnValue(stripes);
render(<IfInterface name="paul,is,dead">monkey</IfInterface>);
expect(screen.queryByText(/monkey/)).toBeFalsy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render, screen } from '@folio/jest-config-stripes/testing-library/react';

import BadRequestScreen from './ResetPasswordNotAvailableScreen';

jest.mock('../../Pluggable', () => (props) => props.children);

describe('ResetPasswordNotAvailableScreen', () => {
it('renders expected message', () => {
render(<BadRequestScreen />);

screen.getByText('stripes-core.front.error.header');
screen.getByText('stripes-core.front.error.setPassword.message');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const FixedLengthSessionWarning = () => {
return '00:00';
};

return <MessageBanner show contentClassName={css.fixedSessionBanner}><FormattedMessage id="stripes-core.rtr.fixedLengthSession.timeRemaining" />{timestampFormatter()}</MessageBanner>;
return <MessageBanner show contentClassName={css.fixedSessionBanner}><FormattedMessage id="stripes-core.rtr.fixedLengthSession.timeRemaining" /> {timestampFormatter()}</MessageBanner>;
};

export default FixedLengthSessionWarning;

0 comments on commit 094fd2f

Please sign in to comment.