Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { describe, expect, test } from 'vitest'; import { GalacticInputValidator, GalacticCodeInputValidator, galacticCodePattern } from './galacticInputValidation'; import type { GlyphInput } from '@/types/glyphTypes'; describe('Galactic Input Validation', () => { describe('general input validation', () => { test('nothing provided is invalid', () => { const inputProps: GlyphInput = {}; expect(GalacticInputValidator(inputProps).isValid).toBeFalsy(); }); }); describe('galactic code validation', () => { test('null code is not valid', () => { const code: any = null; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); test('empty string code is not valid', () => { const code = ''; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); test('too short code is not valid', () => { const code = '1234:'; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); test('invalid in the middle length code is not valid', () => { const code = '1234:1234:1234:14'; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); test('too long code is not valid', () => { const code = '1234:1234:1234:1234:0000'; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); test('contains valid characters', () => { const code = '1234:ABCD:1234:CDEF'; expect(GalacticCodeInputValidator(code).isValid).toBeTruthy(); }); test('contains invalid characters', () => { const code = '1234:test:1234:fred'; expect(GalacticCodeInputValidator(code).isValid).toBeFalsy(); }); }); describe('galactic code pattern validation', () => { test('contains valid characters, semicolons', () => { const code = '1234:1234:1234:1234'; expect(galacticCodePattern(code).isValid).toBeTruthy(); }); test('contains valid characters, no semicolons', () => { const code = '1234123412341234'; expect(galacticCodePattern(code).isValid).toBeTruthy(); }); test('short coords contains invalid semicolon position', () => { const code = '123412341234:234'; expect(galacticCodePattern(code).isValid).toBeFalsy(); }); test('contains invalid semicolon position', () => { const code = '12345:234:1234:1234'; expect(galacticCodePattern(code).isValid).toBeFalsy(); }); test('contains missing semicolon position', () => { const code = '123451234:1234:1234'; expect(galacticCodePattern(code).isValid).toBeFalsy(); }); }); }); |