-
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.
- Loading branch information
1 parent
d460d46
commit 39575fc
Showing
3 changed files
with
58 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,42 @@ | ||
import { getStandard } from '../../src'; | ||
|
||
const generatorName = 'uuid'; | ||
const generatorNameUpper = 'UUID' | ||
|
||
describe('UUIDGenerator', () => { | ||
it('should be able to be found using name', () => { | ||
it('should be able to be found using name (lower)', () => { | ||
expect(() => getStandard(generatorName)).not.toThrow(); | ||
}); | ||
|
||
it('should return a string', () => { | ||
it('should be able to be found using name (upper)', () => { | ||
expect(() => getStandard(generatorNameUpper)).not.toThrow(); | ||
}); | ||
|
||
it('should return a string (lower)', () => { | ||
const generator = getStandard(generatorName); | ||
|
||
expect(typeof generator.generate()).toBe('string'); | ||
}); | ||
|
||
it('should return a string matching the regular expression', () => { | ||
it('should return a string (upper)', () => { | ||
const generator = getStandard(generatorNameUpper); | ||
|
||
expect(typeof generator.generate()).toBe('string'); | ||
}); | ||
|
||
it('should return a string matching the regular expression (lower)', () => { | ||
const regex = | ||
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/; | ||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/; | ||
const generator = getStandard(generatorName); | ||
|
||
expect(regex.test(generator.generate() as string)).toBe(true); | ||
}); | ||
|
||
it('should return a string matching the regular expression (upper)', () => { | ||
const regex = | ||
/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/; | ||
const generator = getStandard(generatorNameUpper); | ||
|
||
expect(regex.test(generator.generate() as string)).toBe(true); | ||
}); | ||
}); |