-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: semantic-release-bot <[email protected]> Co-authored-by: csehatt741 <[email protected]> Co-authored-by: kriptonian1 <[email protected]> Co-authored-by: Allan Joston Fernandes <[email protected]> Co-authored-by: Sawan Bhattacharya <[email protected]>
- Loading branch information
1 parent
7b772f8
commit f3dfe25
Showing
50 changed files
with
1,849 additions
and
203 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { generateSecretValue } from './secret' | ||
|
||
describe('generateSecretValue', () => { | ||
test('should generate a string of exactly 20 characters', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toHaveLength(20) | ||
}) | ||
|
||
test('should include at least one digit', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/\d/) | ||
}) | ||
|
||
test('should include at least one lowercase letter', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[a-z]/) | ||
}) | ||
|
||
test('should include at least one uppercase letter', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[A-Z]/) | ||
}) | ||
|
||
test('should include at least one special character', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[!@#$%^&*]/) | ||
}) | ||
|
||
test('should only include allowed characters', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/^[0-9a-zA-Z!@#$%^&*]{20}$/) | ||
}) | ||
|
||
test('should generate different values for consecutive calls', () => { | ||
const secret1 = generateSecretValue() | ||
const secret2 = generateSecretValue() | ||
expect(secret1).not.toBe(secret2) | ||
}) | ||
}) |
Oops, something went wrong.