feat: add Session and stage active check

This commit is contained in:
wancat committed 2024-03-08 01:05:26 +08:00
1 parent 5bea2ea78c
commit b449ea455a
4 files changed
+62 -5

No files matched your search

+19
View File
@@ -2,6 +2,7 @@ import { test, expect } from '@jest/globals'
import { Stage } from '../src/Stage'
import { FileType } from '../src/types'
import { MockFileChecker } from './asyncCondition.test'
import { Session } from '../src/Session'
const checker = new MockFileChecker()
@@ -67,3 +68,21 @@ test('check stage with async condition falsy', async () => {
})
expect(await stage.satisfies({}, checker)).toBe(false)
})
test('stage active checks', () => {
const session = new Session({
completedStages: ['stage1'],
})
const stage3 = new Stage({
id: 'stage3',
requirements: ['stage1', 'stage2'],
condition: {},
})
expect(stage3.active(session)).toBe(false)
session.complete('stage2')
expect(stage3.active(session)).toBe(true)
session.complete('stage3')
expect(stage3.active(session)).toBe(false)
})