Skip to content

Commit 02ccbf1

Browse files
test: add unit tests for isPasswordValid utility (#30)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 180c4be commit 02ccbf1

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

src/utils/helper.test.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
import { describe, expect, test } from 'bun:test';
2-
import { isExpVersion } from './helper';
2+
import { isExpVersion, isPasswordValid } from './helper';
3+
4+
describe('isPasswordValid', () => {
5+
test('should return true for valid passwords', () => {
6+
expect(isPasswordValid('Passw0rd')).toBe(true);
7+
expect(isPasswordValid('UPPER123')).toBe(true);
8+
expect(isPasswordValid('Valid123')).toBe(true);
9+
});
10+
11+
test('should return false for passwords that are too short', () => {
12+
expect(isPasswordValid('Short')).toBe(false); // 5 chars
13+
expect(isPasswordValid('A1b')).toBe(false); // 3 chars
14+
});
15+
16+
test('should return false for passwords that are too long', () => {
17+
expect(isPasswordValid('ThisPasswordIsWayTooLong123')).toBe(false); // > 16 chars
18+
});
19+
20+
test('should return false for passwords with only digits', () => {
21+
expect(isPasswordValid('12345678')).toBe(false);
22+
});
23+
24+
test('should return false for passwords with only lowercase letters', () => {
25+
expect(isPasswordValid('lowercase')).toBe(false);
26+
});
27+
28+
test('should return false for passwords with no uppercase letters', () => {
29+
expect(isPasswordValid('lower123')).toBe(false);
30+
expect(isPasswordValid('noupper!')).toBe(false);
31+
});
32+
});
333

434
describe('isExpVersion', () => {
535
test('should return false when config is null', () => {

0 commit comments

Comments
 (0)