- Add permissions logic for status options in corrective actions. - Create tests for permissions functionality. - Implement queries for user authentication and actions management. - Develop Actions page to display and manage corrective actions. - Create authentication pages for login, setup, and password reset. - Add IncidentDetail page to view incident details and associated actions. - Implement Settings page for user management and password changes.
20 lines
948 B
TypeScript
20 lines
948 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { detectFileType } from './file-type.ts'
|
|
|
|
const bytes = (...values: (number | string)[]) => new Uint8Array(values.flatMap((v) => (typeof v === 'string' ? [...v].map((ch) => ch.charCodeAt(0)) : [v])))
|
|
|
|
describe('detectFileType', () => {
|
|
it('recognises supported formats', () => {
|
|
expect(detectFileType(bytes(0xff, 0xd8, 0xff, 0xe0))?.contentType).toBe('image/jpeg')
|
|
expect(detectFileType(bytes('RIFF', 0, 0, 0, 0, 'WEBP'))?.contentType).toBe('image/webp')
|
|
expect(detectFileType(bytes(0, 0, 0, 24, 'ftypheic'))?.contentType).toBe('image/heic')
|
|
expect(detectFileType(bytes('%PDF-1.7'))?.contentType).toBe('application/pdf')
|
|
})
|
|
|
|
it('rejects everything else', () => {
|
|
expect(detectFileType(bytes('<svg xmlns="http://www.w3.org/2000/svg">'))).toBeNull()
|
|
expect(detectFileType(bytes('PK', 3, 4))).toBeNull()
|
|
expect(detectFileType(new Uint8Array())).toBeNull()
|
|
})
|
|
})
|