From eb141980127a96f264c474480603f763ea0fd321 Mon Sep 17 00:00:00 2001 From: Neil Mills Date: Wed, 29 Jan 2025 17:14:00 +0000 Subject: [PATCH] MAN-274 add unit test for make page title utility function --- server/utils/utils.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/utils/utils.test.ts b/server/utils/utils.test.ts index ab0717bb..a9134383 100644 --- a/server/utils/utils.test.ts +++ b/server/utils/utils.test.ts @@ -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 = [ { @@ -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}`, + ) + }) +})