diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 01:02:58 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 01:02:58 +0200 |
| commit | cac85db02ff00732cf75d473dc3411332f33d845 (patch) | |
| tree | 5f244968a905eb3888434b3f60cbf05d2b652207 /src/lib/utils/glyph_hash.test.ts | |
| parent | a7cf03c192470cbab13edeb1aec99e0c66dede10 (diff) | |
Apply formatting
Diffstat (limited to 'src/lib/utils/glyph_hash.test.ts')
| -rw-r--r-- | src/lib/utils/glyph_hash.test.ts | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/src/lib/utils/glyph_hash.test.ts b/src/lib/utils/glyph_hash.test.ts index 5f57a2a..e791bab 100644 --- a/src/lib/utils/glyph_hash.test.ts +++ b/src/lib/utils/glyph_hash.test.ts @@ -2,67 +2,55 @@ import { getGlyphHash } from './glyph_hash'; import type { GlyphHash } from './glyph_hash'; type TestState = { - glyphHash?: GlyphHash + glyphHash?: GlyphHash; }; - describe('Glyph Hash utility', () => { + test('it throws an exception if the string is too short', () => { + expect(() => { + getGlyphHash('short'); + }).toThrow(); - test('it throws an exception if the string is too short', () => { - - expect(() => { - - getGlyphHash('short'); - }).toThrow(); - - expect(() => { - - getGlyphHash('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); - }).toThrow(); - - expect(() => { - - getGlyphHash('abcdefghijklmnopqrstuvwxyzABCDEF'); - }).not.toThrow(); - }); - - test('it treats UUIDs with hyphens the same as those without', () => { - - const uuidWithHyphens = 'f7722355-2285-46c0-a55f-3483a826f3a6'; - const uuidWithoutHyphens = 'f7722355228546c0a55f3483a826f3a6'; - - expect(getGlyphHash(uuidWithHyphens)).toEqual(getGlyphHash(uuidWithoutHyphens)); - }); - - describe('it generates four sets of glyphs and colors', () => { - - const state: TestState = {}; + expect(() => { + getGlyphHash('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); + }).toThrow(); - beforeEach(() => { + expect(() => { + getGlyphHash('abcdefghijklmnopqrstuvwxyzABCDEF'); + }).not.toThrow(); + }); - state.glyphHash = getGlyphHash('f7722355-2285-46c0-a55f-3483a826f3a6'); - }); + test('it treats UUIDs with hyphens the same as those without', () => { + const uuidWithHyphens = 'f7722355-2285-46c0-a55f-3483a826f3a6'; + const uuidWithoutHyphens = 'f7722355228546c0a55f3483a826f3a6'; - test('there should be four glyph fragments', () => { + expect(getGlyphHash(uuidWithHyphens)).toEqual(getGlyphHash(uuidWithoutHyphens)); + }); - expect(state.glyphHash.length).toBe(4); - }); + describe('it generates four sets of glyphs and colors', () => { + const state: TestState = {}; - test('each fragment should have a single character glyph', () => { + beforeEach(() => { + state.glyphHash = getGlyphHash('f7722355-2285-46c0-a55f-3483a826f3a6'); + }); - for (const glyphHashFragment of state.glyphHash) { - expect(typeof glyphHashFragment.glyph).toBe('string'); - expect(glyphHashFragment.glyph.length).toBe(1); - } - }); + test('there should be four glyph fragments', () => { + expect(state.glyphHash.length).toBe(4); + }); - test('each fragment should have a hexadecimal color', () => { + test('each fragment should have a single character glyph', () => { + for (const glyphHashFragment of state.glyphHash) { + expect(typeof glyphHashFragment.glyph).toBe('string'); + expect(glyphHashFragment.glyph.length).toBe(1); + } + }); - for (const glyphHashFragment of state.glyphHash) { - expect(typeof glyphHashFragment.color).toBe('string'); - expect(glyphHashFragment.color.length).toBe(7); - expect(glyphHashFragment.color).toEqual(expect.stringMatching(/#[0-9a-f]{6}/)); - } - }); - }); + test('each fragment should have a hexadecimal color', () => { + for (const glyphHashFragment of state.glyphHash) { + expect(typeof glyphHashFragment.color).toBe('string'); + expect(glyphHashFragment.color.length).toBe(7); + expect(glyphHashFragment.color).toEqual(expect.stringMatching(/#[0-9a-f]{6}/)); + } + }); + }); }); |