Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma strängvärde byggs med konkatenering i stället för att matcha mönstret.
25 lines
975 B
TypeScript
25 lines
975 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { UUID_RE, isUuid } from '../uuid'
|
|
|
|
describe('UUID_RE / isUuid', () => {
|
|
it('accepts lower- and upper-case hex layouts', () => {
|
|
expect(isUuid('123e4567-e89b-12d3-a456-426614174000')).toBe(true)
|
|
expect(isUuid('123E4567-E89B-12D3-A456-426614174000')).toBe(true)
|
|
expect(UUID_RE.test('00000000-0000-0000-0000-000000000000')).toBe(true)
|
|
})
|
|
|
|
it('rejects anything that is not exactly the 8-4-4-4-12 shape', () => {
|
|
expect(isUuid('123e4567e89b12d3a456426614174000')).toBe(false)
|
|
expect(isUuid('123e4567-e89b-12d3-a456-42661417400')).toBe(false)
|
|
expect(isUuid('123e4567-e89b-12d3-a456-426614174000,x.eq.1')).toBe(false)
|
|
expect(isUuid(' 123e4567-e89b-12d3-a456-426614174000')).toBe(false)
|
|
expect(isUuid('')).toBe(false)
|
|
})
|
|
|
|
it('narrows non-strings to false', () => {
|
|
expect(isUuid(null)).toBe(false)
|
|
expect(isUuid(undefined)).toBe(false)
|
|
expect(isUuid(42)).toBe(false)
|
|
})
|
|
})
|