mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 06:44:58 +00:00
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { validateLuaScriptCreate } from '../../../src/core/validation/validate-lua-script-create'
|
|
|
|
describe('validateLuaScriptCreate', () => {
|
|
const base = {
|
|
name: 'daily-cleanup',
|
|
code: 'return true',
|
|
isSandboxed: true,
|
|
allowedGlobals: ['math'],
|
|
timeoutMs: 5000,
|
|
createdBy: '550e8400-e29b-41d4-a716-446655440000',
|
|
}
|
|
|
|
it.each([
|
|
{ data: base, expected: [] },
|
|
])('returns $expected for valid case', ({ data, expected }) => {
|
|
expect(validateLuaScriptCreate(data)).toEqual(expected)
|
|
})
|
|
|
|
it.each([
|
|
{ data: { ...base, allowedGlobals: 'math' as unknown as string[] }, message: 'allowedGlobals must be an array of strings' },
|
|
{ data: { ...base, allowedGlobals: [''] }, message: 'allowedGlobals must contain non-empty strings' },
|
|
{ data: { ...base, timeoutMs: 50 }, message: 'timeoutMs must be an integer between 100 and 30000' },
|
|
{ data: { ...base, createdBy: 'invalid' }, message: 'createdBy must be a valid UUID' },
|
|
])('rejects invalid case', ({ data, message }) => {
|
|
expect(validateLuaScriptCreate(data)).toContain(message)
|
|
})
|
|
})
|