mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
feat: add get responses
This commit is contained in:
1 parent
dae9e841ca
commit
f7780c3d98
9 files changed
+94
-54
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@jest/globals'
|
||||
import { IFileExistenceChecker, FileType, FileInput } from '../src/types.js'
|
||||
import { IFileExistenceChecker, FileType, FileInput } from '../src/schema'
|
||||
import { checkFiles } from '../src/condition/FileMatcher.js'
|
||||
import { Condition } from '../src/condition/Condition.js'
|
||||
|
||||
|
||||
@@ -92,4 +92,26 @@ describe('Session', () => {
|
||||
'stage4'
|
||||
)
|
||||
})
|
||||
|
||||
it('should return responses', () => {
|
||||
const session = new Session(
|
||||
{
|
||||
completedStages: ['stage1'],
|
||||
},
|
||||
quest,
|
||||
new MockFileChecker()
|
||||
)
|
||||
expect(session.getResponses()).toEqual([
|
||||
{
|
||||
type: 'narrative',
|
||||
content: 'Narrative 1',
|
||||
},
|
||||
])
|
||||
|
||||
session.complete('stage2')
|
||||
expect(session.getResponses()).toEqual([
|
||||
{ type: 'narrative', content: 'Narrative 1' },
|
||||
{ type: 'narrative', content: 'Narrative 2' },
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { test, expect } from '@jest/globals'
|
||||
import { Stage } from '../src/Stage'
|
||||
import { FileType } from '../src/types'
|
||||
import { FileType } from '../src/schema'
|
||||
import { MockFileChecker } from './asyncCondition.test'
|
||||
|
||||
const checker = new MockFileChecker()
|
||||
@@ -13,6 +13,11 @@ test('check stage condition', async () => {
|
||||
command: 'ls',
|
||||
pwd: '/home/user',
|
||||
},
|
||||
requirements: [],
|
||||
response: {
|
||||
type: 'narrative',
|
||||
content: 'Narrative 1',
|
||||
},
|
||||
})
|
||||
expect(
|
||||
await stage.satisfies(
|
||||
@@ -47,6 +52,11 @@ test('check stage with async condition truthy', async () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
requirements: [],
|
||||
response: {
|
||||
type: 'narrative',
|
||||
content: 'Narrative 1',
|
||||
},
|
||||
})
|
||||
expect(await stage.satisfies({}, checker)).toBe(true)
|
||||
})
|
||||
@@ -64,6 +74,11 @@ test('check stage with async condition falsy', async () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
requirements: [],
|
||||
response: {
|
||||
type: 'narrative',
|
||||
content: 'Narrative 1',
|
||||
},
|
||||
})
|
||||
expect(await stage.satisfies({}, checker)).toBe(false)
|
||||
})
|
||||
Reference in new issue
Block a user