feat: add checkfiles into Condition

This commit is contained in:
wancat committed 2024-03-08 00:24:51 +08:00
1 parent d612b2d6af
commit 65ad72223b
4 files changed
+36 -8

No files matched your search

+15
View File
@@ -1,6 +1,7 @@
import { test, expect } from '@jest/globals'
import { IFileExistenceChecker, FileType, FileInput } from '../src/types.js'
import { checkFiles } from '../src/condition/FileMatcher.js'
import { Condition } from '../src/condition/Condition.js'
class MockFileChecker implements IFileExistenceChecker {
private files: FileInput[] = [
@@ -90,3 +91,17 @@ test('file matcher', async () => {
])
).toBe(false)
})
test('condition with file matcher', async () => {
const checker = new MockFileChecker()
const condition = new Condition({
files: [
{
path: '/home/user/hello.txt',
type: FileType.FILE,
exists: true,
},
],
})
expect(await condition.check(checker)).toBe(true)
})