diff --git a/src/utils/StringIdGenerator.ts b/src/utils/StringIdGenerator.ts index 9e580c77..58861cc4 100644 --- a/src/utils/StringIdGenerator.ts +++ b/src/utils/StringIdGenerator.ts @@ -1,3 +1,5 @@ +// TODO @Shinigami92 2024-04-03: Can this be fully rewritten to a generator function? + // credits to https://stackoverflow.com/a/12504061/4790644 export class StringIdGenerator { private ids: number[] = [0]; diff --git a/test/utils/StringIdGenerator.spec.ts b/test/utils/StringIdGenerator.spec.ts index ddc8cf9c..f368f0ad 100644 --- a/test/utils/StringIdGenerator.spec.ts +++ b/test/utils/StringIdGenerator.spec.ts @@ -3,7 +3,16 @@ import { StringIdGenerator } from '../../src/utils'; describe('utils', () => { describe('StringIdGenerator', () => { - it('should generate correct sequence', () => { + it('should generate correct sequence with default chars', () => { + const ids = new StringIdGenerator(); + const results = [...'abcdefghijklmnopqrstuvwxyz', 'aa', 'ab']; + + results.forEach((res) => { + expect(ids.next()).toBe(res); + }); + }); + + it('should generate correct sequence with custom chars', () => { const chars = 'abcd'; const ids = new StringIdGenerator(chars);