-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`)); | ||
}); | ||
}); |