mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
wip: game schema
This commit is contained in:
1 parent
e66598f1a7
commit
19c44fbe52
7 files changed
+70
-2
No files matched your search
@@ -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()
|
||||
})
|
||||
Reference in new issue
Block a user