-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
84d55ca
commit 4b190d7
Showing
7 changed files
with
85 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
VideoWeb/VideoWeb/ClientApp/src/app/shared/translation-id-converter.spec.ts
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { convertStringToTranslationId } from './translation-id-converter'; | ||
|
||
describe('convertStringToTranslationId', () => { | ||
it('should return an empty string if input is null', () => { | ||
const result = convertStringToTranslationId(null); | ||
expect(result).toEqual(''); | ||
}); | ||
|
||
it('should return an empty string if input is undefined', () => { | ||
const result = convertStringToTranslationId(undefined); | ||
expect(result).toEqual(''); | ||
}); | ||
|
||
it('should return the correct string to translate id', () => { | ||
const result = convertStringToTranslationId('Insolvency'); | ||
expect(result).toBe('insolvency'); | ||
}); | ||
|
||
it('should return the correct string to translate id with spaces', () => { | ||
const result = convertStringToTranslationId('Primary Health Lists'); | ||
expect(result).toBe('primary-health-lists'); | ||
}); | ||
|
||
it('should return the correct string to translate id with spaces and special characters', () => { | ||
const result = convertStringToTranslationId('MP’s Expenses'); | ||
expect(result).toBe('mp-s-expenses'); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
VideoWeb/VideoWeb/ClientApp/src/app/shared/translation-id-converter.ts
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function convertStringToTranslationId(str): string { | ||
if (!str) { | ||
return ''; | ||
} | ||
return str.replace(/[\s’']/g, '-').toLowerCase(); | ||
} |
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