mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
code: validate,script,lua (1 files)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { validateLuaScriptCreate } from './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 },
|
||||
])('accepts %s', ({ data }) => {
|
||||
expect(validateLuaScriptCreate(data)).toEqual([])
|
||||
})
|
||||
|
||||
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 %s', ({ data, message }) => {
|
||||
expect(validateLuaScriptCreate(data)).toContain(message)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user