generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDI-265: ♻️ Minor improvements (#107)
- Loading branch information
1 parent
a6ac4cb
commit a71978d
Showing
7 changed files
with
38 additions
and
42 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
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
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
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 |
---|---|---|
@@ -1,31 +1,30 @@ | ||
import convertToTitleCase from './utils' | ||
import { convertToTitleCase, initialiseName } from './utils' | ||
|
||
describe('Convert to title case', () => { | ||
it('null string', () => { | ||
expect(convertToTitleCase(null)).toEqual('') | ||
describe('convert to title case', () => { | ||
it.each([ | ||
[null, null, ''], | ||
['empty string', '', ''], | ||
['Lower case', 'robert', 'Robert'], | ||
['Upper case', 'ROBERT', 'Robert'], | ||
['Mixed case', 'RoBErT', 'Robert'], | ||
['Multiple words', 'RobeRT SMiTH', 'Robert Smith'], | ||
['Leading spaces', ' RobeRT', ' Robert'], | ||
['Trailing spaces', 'RobeRT ', 'Robert '], | ||
['Hyphenated', 'Robert-John SmiTH-jONes-WILSON', 'Robert-John Smith-Jones-Wilson'], | ||
])('%s convertToTitleCase(%s, %s)', (_: string, a: string, expected: string) => { | ||
expect(convertToTitleCase(a)).toEqual(expected) | ||
}) | ||
it('empty string', () => { | ||
expect(convertToTitleCase('')).toEqual('') | ||
}) | ||
it('Lower Case', () => { | ||
expect(convertToTitleCase('robert')).toEqual('Robert') | ||
}) | ||
it('Upper Case', () => { | ||
expect(convertToTitleCase('ROBERT')).toEqual('Robert') | ||
}) | ||
it('Mixed Case', () => { | ||
expect(convertToTitleCase('RoBErT')).toEqual('Robert') | ||
}) | ||
it('Multiple words', () => { | ||
expect(convertToTitleCase('RobeRT SMiTH')).toEqual('Robert Smith') | ||
}) | ||
it('Leading spaces', () => { | ||
expect(convertToTitleCase(' RobeRT')).toEqual(' Robert') | ||
}) | ||
it('Trailing spaces', () => { | ||
expect(convertToTitleCase('RobeRT ')).toEqual('Robert ') | ||
}) | ||
it('Hyphenated', () => { | ||
expect(convertToTitleCase('Robert-John SmiTH-jONes-WILSON')).toEqual('Robert-John Smith-Jones-Wilson') | ||
}) | ||
|
||
describe('initialise name', () => { | ||
it.each([ | ||
[null, null, null], | ||
['Empty string', '', null], | ||
['One word', 'robert', 'r. robert'], | ||
['Two words', 'Robert James', 'R. James'], | ||
['Three words', 'Robert James Smith', 'R. Smith'], | ||
['Double barrelled', 'Robert-John Smith-Jones-Wilson', 'R. Smith-Jones-Wilson'], | ||
])('%s initialiseName(%s, %s)', (_: string, a: string, expected: string) => { | ||
expect(initialiseName(a)).toEqual(expected) | ||
}) | ||
}) |
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
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
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