0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00
logto/packages/shared/src/utils/id.test.ts

30 lines
819 B
TypeScript
Raw Normal View History

import { generateStandardId, generateStandardSecret, generateStandardShortId } from './id.js';
describe('standard id generator', () => {
it('should match the input length', () => {
const id = generateStandardId();
expect(id.length).toEqual(21);
});
});
describe('standard short id generator', () => {
it('should match the input length', () => {
const id = generateStandardShortId();
expect(id.length).toEqual(12);
});
});
describe('standard secret generator', () => {
it('should match the input length', () => {
const id = generateStandardSecret();
expect(id.length).toEqual(32);
});
it('should generate id with uppercase', () => {
// If it can't generate uppercase, it will timeout
while (!/[A-Z]/.test(generateStandardSecret())) {
// Do nothing
}
});
});