mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add global exceptions
This commit is contained in:
1 parent
fb823814e0
commit
cfce5ececa
6 files changed
+71
-5
No files matched your search
@@ -43,6 +43,24 @@ const quest: IQuest = {
|
||||
response: { type: 'narrative', content: 'Narrative 2' },
|
||||
},
|
||||
],
|
||||
exceptions: [
|
||||
{
|
||||
id: 'exception3',
|
||||
condition: {
|
||||
command: 'rm',
|
||||
},
|
||||
response: { type: 'narrative', content: 'Exception 3' },
|
||||
requirements: [],
|
||||
},
|
||||
{
|
||||
id: 'exception4',
|
||||
condition: {
|
||||
command: 'mv',
|
||||
},
|
||||
response: { type: 'narrative', content: 'Exception 4' },
|
||||
requirements: ['stage1'],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
describe('exceptions', () => {
|
||||
@@ -57,4 +75,16 @@ describe('exceptions', () => {
|
||||
console.log('completed', session.completedStages)
|
||||
expect(await session.runCommand({ command: 'ls' })).toBe('stage2')
|
||||
})
|
||||
|
||||
it('should return the global exception', async () => {
|
||||
const session = new Session(
|
||||
{ completedStages: [] },
|
||||
quest,
|
||||
new MockFileChecker()
|
||||
)
|
||||
expect(await session.runCommand({ command: 'rm' })).toBe('exception3')
|
||||
expect(await session.runCommand({ command: 'mv' })).toBeNull()
|
||||
session.complete('stage1')
|
||||
expect(await session.runCommand({ command: 'mv' })).toBe('exception4')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user