|
1 | | -import { nextUuid, resetNextUuid } from './uuid'; |
| 1 | +import { assertValidHtmlId, nextUuid, resetNextUuid } from './uuid'; |
2 | 2 |
|
3 | 3 | describe('UUID helper', () => { |
4 | 4 | describe('nextUuid', () => { |
5 | 5 | it('generates incremental uuids', () => { |
6 | | - expect(nextUuid()).toBe(0); |
7 | | - expect(nextUuid()).toBe(1); |
| 6 | + expect(nextUuid()).toBe('raa-0'); |
| 7 | + expect(nextUuid()).toBe('raa-1'); |
8 | 8 | }); |
9 | 9 | }); |
10 | 10 |
|
11 | 11 | describe('resetNextUuid', () => { |
12 | 12 | it('resets the uuid', () => { |
13 | 13 | resetNextUuid(); |
14 | | - expect(nextUuid()).toBe(0); |
| 14 | + expect(nextUuid()).toBe('raa-0'); |
15 | 15 | resetNextUuid(); |
16 | | - expect(nextUuid()).toBe(0); |
| 16 | + expect(nextUuid()).toBe('raa-0'); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('assertValidHtmlId', () => { |
| 21 | + it("returns false in case there's a whitespace or an empty string", () => { |
| 22 | + expect(assertValidHtmlId('a a')).toBe(false); |
| 23 | + expect(assertValidHtmlId('')).toBe(false); |
| 24 | + }); |
| 25 | + |
| 26 | + it('returns true on a valid id', () => { |
| 27 | + expect(assertValidHtmlId('💜')).toBe(true); |
| 28 | + expect(assertValidHtmlId('✅')).toBe(true); |
17 | 29 | }); |
18 | 30 | }); |
19 | 31 | }); |
0 commit comments