From 69fedde10d0854ac8e77da11e029b054168d1219 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Thu, 8 Jun 2023 17:48:49 +0100 Subject: [PATCH] =?UTF-8?q?Ignore=20=E2=80=9CCharacter=20count=E2=80=9D=20?= =?UTF-8?q?private=20method=20access=20for=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ideally we should update our tests to access only public methods, perhaps making getters/setters for things like `getCountMessage()` instead? --- .../character-count.unit.test.mjs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/govuk-frontend/src/govuk/components/character-count/character-count.unit.test.mjs b/packages/govuk-frontend/src/govuk/components/character-count/character-count.unit.test.mjs index d2ca4f2972..1b8f95cd7d 100644 --- a/packages/govuk-frontend/src/govuk/components/character-count/character-count.unit.test.mjs +++ b/packages/govuk-frontend/src/govuk/components/character-count/character-count.unit.test.mjs @@ -55,8 +55,11 @@ describe('CharacterCount', () => { i18n: { charactersUnderLimit: { one: 'Custom text. Count: %{count}' } } }) + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(1, 'characters')).toEqual('Custom text. Count: 1') + // Other keys remain untouched + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(10, 'characters')).toEqual('You have 10 characters remaining') }) @@ -69,7 +72,10 @@ describe('CharacterCount', () => { } }) + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(0, 'characters')).toEqual('Custom text.') + + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(0, 'words')).toEqual('Different custom text.') }) }) @@ -81,6 +87,7 @@ describe('CharacterCount', () => { const component = new CharacterCount($div) + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(10000, 'words')).toEqual('You have 10.000 words remaining') }) @@ -93,6 +100,7 @@ describe('CharacterCount', () => { const component = new CharacterCount($div) + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(10000, 'words')).toEqual('You have 10.000 words remaining') }) }) @@ -104,8 +112,11 @@ describe('CharacterCount', () => { const component = new CharacterCount($div) + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(1, 'characters')).toEqual('Custom text. Count: 1') + // Other keys remain untouched + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(10, 'characters')).toEqual('You have 10 characters remaining') }) @@ -121,9 +132,15 @@ describe('CharacterCount', () => { } } }) + + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(1, 'characters')).toEqual('Custom text. Count: 1') + // Other keys remain untouched + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(-10, 'characters')).toEqual('You have 10 characters too many') + + // @ts-expect-error Property 'formatCountMessage' is private expect(component.formatCountMessage(0, 'characters')).toEqual('You have 0 characters remaining') }) })