|
1 | 1 | 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 | +}); |
3 | 33 |
|
4 | 34 | describe('isExpVersion', () => { |
5 | 35 | test('should return false when config is null', () => { |
|
0 commit comments