Skip to content

Commit

Permalink
Ignore “Character count” private method access for tests
Browse files Browse the repository at this point in the history
Ideally we should update our tests to access only public methods, perhaps making getters/setters for things like `getCountMessage()` instead?
  • Loading branch information
colinrotherham committed Jun 8, 2023
1 parent a592344 commit 69fedde
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand All @@ -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.')
})
})
Expand All @@ -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')
})

Expand All @@ -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')
})
})
Expand All @@ -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')
})

Expand All @@ -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')
})
})
Expand Down

0 comments on commit 69fedde

Please sign in to comment.