Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/falso/src/lib/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type RandomSequenceOptions2 = {
// Helper type to determine the return type based on `charType`
type ReturnTypeFromCharType<CharType extends CharTypes | undefined> =
CharType extends 'numeric' | 'alpha' | 'alphaNumeric' | 'special'
? string
: string[];
? CharType
: string;

/**
* Generate a random sequence.
Expand Down
21 changes: 21 additions & 0 deletions packages/falso/src/tests/password.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { randPassword } from '../lib/password';

describe('randPassword', () => {
it('should generate a string of default length 15 with default chars', () => {
const result = randPassword();
expect(result).toHaveLength(15); // Default length should be 15
expect(typeof result).toBe('string'); // Result should be a string
});

it('should generate a string of length 10 with default chars', () => {
const result = randPassword({ size: 10 });
expect(result).toHaveLength(10);
expect(typeof result).toBe('string'); // Result should be a string
});

it('should generate am array string of length 10 with default chars', () => {
const result = randPassword({ length: 10 });
expect(result).toHaveLength(10);
expect(result.length).toBe(10);
});
});