-
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
9b73052
commit 5cb072b
Showing
3 changed files
with
57 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,26 @@ | ||
// import {describe, expect, test} from '@jest/globals'; | ||
import { getPasswordStrengthResult } from '../PasswordStrengthInput'; | ||
|
||
// ------------ default options ------------ // | ||
describe('check default labels', () => { | ||
test('tooWeak label', () => { | ||
expect(getPasswordStrengthResult('tooWeak').label).toBe('Too weak'); | ||
}); | ||
|
||
test('weak label', () => { | ||
expect(getPasswordStrengthResult('weak').label).toBe('Weak'); | ||
}); | ||
|
||
test('medium label', () => { | ||
expect(getPasswordStrengthResult('medium').label).toBe('Okay'); | ||
}); | ||
import { getPasswordScoreAndCriteria } from "../utils"; | ||
|
||
test('strong label', () => { | ||
expect(getPasswordStrengthResult('strong').label).toBe('Strong'); | ||
}); | ||
}); | ||
|
||
// ------------ custom options ------------ // | ||
describe('check override labels', () => { | ||
test('custom label', () => { | ||
const option = getPasswordStrengthResult('tooWeak', { tooWeak: { label: 'Too weak 2' } }); | ||
expect(option.label).toBe('Too weak 2'); | ||
// ------------ default options ------------ // | ||
describe('check password', () => { | ||
test('check min length', () => { | ||
const { allChecksPassed, errorMessages } = getPasswordScoreAndCriteria('abcde') | ||
expect(allChecksPassed).toBe(false); | ||
const currentPassed = errorMessages.find((error) => error.key === 'lowerCase'); | ||
expect(currentPassed?.pass).toBe(true); | ||
}); | ||
|
||
test('custom color', () => { | ||
const option = getPasswordStrengthResult('medium', { medium: { color: 'red' } }); | ||
expect(option.color).toBe('red'); | ||
test('check two passed check', () => { | ||
const { allChecksPassed, errorMessages } = getPasswordScoreAndCriteria('abcde8') | ||
expect(allChecksPassed).toBe(false); | ||
const passedChecks = errorMessages.filter((error) => error.key && ['lowerCase', 'number'].includes(error.key)); | ||
expect(passedChecks?.length).toBe(2); | ||
}); | ||
|
||
test('custom color and label', () => { | ||
const option = getPasswordStrengthResult('strong', { strong: { color: 'red', label: 'Strong 2' } }); | ||
expect(option.label).toBe('Strong 2'); | ||
expect(option.color).toBe('red'); | ||
test('check all checks passed', () => { | ||
const { allChecksPassed, errorMessages } = getPasswordScoreAndCriteria('abcde8=F') | ||
expect(allChecksPassed).toBe(true); | ||
expect(errorMessages?.length).toBe(5); | ||
}); | ||
}); |
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