Skip to content

Commit

Permalink
test <TitleManager> (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke committed May 29, 2024
1 parent 4312058 commit 80bda77
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/components/TitleManager/TitleManager.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { render, waitFor } from '@folio/jest-config-stripes/testing-library/react';
import { createMemoryHistory } from 'history';

import TitleManager from './TitleManager';
import Harness from '../../../test/jest/helpers/harness';

describe('TitleManager', () => {
it('renders a title with a default postfix', async () => {
const stripes = {
config: {},
hasPerm: jest.fn(),
};

const page = 'record-application';

const history = createMemoryHistory();
render(
<Harness history={history} stripes={stripes}>
<TitleManager page={page}>
<>thunder - chicken</>
</TitleManager>
</Harness>
);

await waitFor(() => expect(document.title).toBe(`${page} - FOLIO`));
});

it('renders prefix, page, record, postfix', async () => {
const stripes = {
config: {
platformName: 'two mile',
},
hasPerm: jest.fn(),
};

const prefix = 'pre';
const page = 'steve';
const record = '8:41.5';

const history = createMemoryHistory();
render(
<Harness history={history} stripes={stripes}>
<TitleManager page={page} prefix={prefix} record={record}>
<>thunder - chicken</>
</TitleManager>
</Harness>
);

await waitFor(() => expect(document.title).toBe(`${prefix}${page} - ${record} - ${stripes.config.platformName}`));
});


it('renders prefix, record, postfix', async () => {
const stripes = {
config: {
platformName: 'two mile',
},
hasPerm: jest.fn(),
};

const prefix = 'pre';
const record = '8:41.5';

const history = createMemoryHistory();
render(
<Harness history={history} stripes={stripes}>
<TitleManager prefix={prefix} record={record}>
<>thunder - chicken</>
</TitleManager>
</Harness>
);

await waitFor(() => expect(document.title).toBe(`${prefix}${record} - ${stripes.config.platformName}`));
});
});

0 comments on commit 80bda77

Please sign in to comment.