diff --git a/shared/utils/keys.ts b/shared/utils/keys.ts index 4e59f1bf..2b6397dc 100644 --- a/shared/utils/keys.ts +++ b/shared/utils/keys.ts @@ -19,3 +19,17 @@ export function createKey(prefix: ValueOf, 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(); + }); + }); +}