feat: add output matcher

This commit is contained in:
wancat committed 2024-03-06 23:32:23 +08:00
1 parent 9eb08b45f4
commit cb26e1dcb0
2 files changed
+14

No files matched your search

+8
View File
@@ -4,6 +4,7 @@ import {
CommandMatcher,
ErrorMatcher,
PwdMatcher,
OutputMatcher,
Condition,
} from '../src/condition'
import { Command } from '../src/command'
@@ -63,6 +64,13 @@ test('pwd matcher', () => {
expect(matcher.match({ pwd: '/var/home/user' })).toBe(false)
})
test('output matcher', () => {
const matcher = new OutputMatcher('^start$')
expect(matcher.match({ output: 'start' })).toBe(true)
expect(matcher.match({ output: 'start1' })).toBe(false)
expect(matcher.match({ output: 'start\n' })).toBe(true)
})
// test('condition match', () => {
// const condition = new Condition({
// command: '^echo start$',