mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add "or" and "not" matchers
This commit is contained in:
1 parent
e83d913852
commit
e5f5590a67
4 files changed
+49
-1
No files matched your search
@@ -62,3 +62,21 @@ test('condition match command', () => {
|
||||
condition.match({ command: 'echo start', error: 'permission denied' })
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
test('condition with OR', () => {
|
||||
const condition = new Condition({
|
||||
or: [{ command: '^echo start$' }, { command: '^echo hello$' }],
|
||||
})
|
||||
expect(condition.match({ command: 'echo start' })).toBe(true)
|
||||
expect(condition.match({ command: 'echo hello' })).toBe(true)
|
||||
expect(condition.match({ command: 'echo start1' })).toBe(false)
|
||||
})
|
||||
|
||||
test('condition with NOT', () => {
|
||||
const condition = new Condition({
|
||||
not: { command: '^echo start$' },
|
||||
})
|
||||
|
||||
expect(condition.match({ command: 'echo start' })).toBe(false)
|
||||
expect(condition.match({ command: 'echo hello' })).toBe(true)
|
||||
})
|
||||
Reference in new issue
Block a user