Skip to content

Commit

Permalink
test: cover keys
Browse files Browse the repository at this point in the history
  • Loading branch information
logotip4ik committed Nov 8, 2024
1 parent bda712e commit a71fac4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions shared/utils/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ export function createKey(prefix: ValueOf<typeof KeyPrefix>, size?: number) {

return `${prefix}_${nanoid(size)}`;
}

if (import.meta.vitest) {
const { describe, it, expect } = import.meta.vitest;

describe('createKey', () => {
it('should create key with specified length', () => {
expect(() => createKey(KeyPrefix.Build)).not.toThrow();
});

it('should throw when key length is too small', () => {
expect(() => createKey(KeyPrefix.Build, 11)).toThrow();
});
});
}

0 comments on commit a71fac4

Please sign in to comment.