wip: game schema

This commit is contained in:
Justin Lin committed 2024-10-10 16:22:20 +08:00
1 parent e66598f1a7
commit 19c44fbe52
7 files changed
+70 -2

No files matched your search

+12
View File
@@ -4,6 +4,7 @@ import { OutputMatcher } from '../src/condition/OutputMatcher'
import { PwdMatcher } from '../src/condition/PwdMatcher'
import { CommandMatcher } from '../src/condition/CommandMatcher'
import { ErrorMatcher } from '../src/condition/ErrorMatcher.js'
import { conditionSchema } from '../src/schema'
test('command match', () => {
const matcher = new CommandMatcher('^echo start$')
@@ -80,3 +81,14 @@ test('condition with NOT', () => {
expect(condition.match({ command: 'echo start' })).toBe(false)
expect(condition.match({ command: 'echo hello' })).toBe(true)
})
it('should parse condition', () => {
const condition = {
command: 'echo start',
output: 'start',
not: {
pwd: '/home/user',
},
}
expect(conditionSchema.safeParse(condition).error).toBeUndefined()
})