Skip to content

Commit

Permalink
MAN-274 add unit test for make page title utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-mills committed Jan 29, 2025
1 parent 5599a1f commit eb14198
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions server/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ import {
timeFromTo,
toYesNo,
yearsSince,
makePageTitle,
} from './utils'
import { RiskResponse, RiskScore, RiskToSelf } from '../data/arnsApiClient'
import { Name } from '../data/model/common'
import { Activity } from '../data/model/schedule'
import { RecentlyViewedCase, UserAccess } from '../data/model/caseAccess'
import config from '../config'

const appointments = [
{
Expand Down Expand Up @@ -487,3 +489,19 @@ describe('update lao access in local storage', () => {
expect(result[0].limitedAccess).toEqual(expected)
})
})

describe('makePageTitle()', () => {
it('should format the title correctly if heading is a single string value', () => {
expect(makePageTitle({ pageHeading: 'Home' })).toEqual(`Home - ${config.applicationName}`)
})
it('should format the title correctly if heading is an array containing two values', () => {
expect(makePageTitle({ pageHeading: ['Contact', 'Personal details'] })).toEqual(
`Contact - Personal details - ${config.applicationName}`,
)
})
it('should format the title correctly if heading is an array containing three values', () => {
expect(makePageTitle({ pageHeading: ['Contact', 'Sentence', 'Licence condition'] })).toEqual(
`Contact - Sentence - Licence condition - ${config.applicationName}`,
)
})
})

0 comments on commit eb14198

Please sign in to comment.