-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from m-h-c-t/mousoleum-stager
Mousoleum Stager
- Loading branch information
Showing
8 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {type User} from '@scripts/types/hg'; | ||
import {type IntakeMessage} from '@scripts/types/mhct'; | ||
import {type IStager} from '../stages.types'; | ||
|
||
export class MousoleumStager implements IStager { | ||
readonly environment: string = 'Mousoleum'; | ||
|
||
/* Add the "wall state" for Mousoleum hunts */ | ||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
if (!userPre.quests.QuestMousoleum) { | ||
throw new Error('QuestMousoleum is undefined'); | ||
} | ||
|
||
message.stage = (userPre.quests.QuestMousoleum.has_wall) ? "Has Wall" : "No Wall"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface QuestMousoleum { | ||
has_wall: boolean; | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/scripts/modules/stages/environments/mousoleum.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {MousoleumStager} from '@scripts/modules/stages/environments/mousoleum'; | ||
import {User} from '@scripts/types/hg'; | ||
import {IntakeMessage} from '@scripts/types/mhct'; | ||
|
||
describe('MousoleumStager', () => { | ||
it('sets stage to "Has Wall" if user has Mousoleum wall', () => { | ||
const stager = new MousoleumStager(); | ||
|
||
const message = {stage: null} as IntakeMessage; | ||
const userPre = {quests: {QuestMousoleum: {has_wall: true}}} as User; | ||
const userPost = {} as User; | ||
const journal = {}; | ||
stager.addStage(message, userPre, userPost, journal); | ||
expect(message.stage).toBe('Has Wall'); | ||
}); | ||
|
||
it('sets stage to "No Wall" if user does not have Mousoleum wall', () => { | ||
const stager = new MousoleumStager(); | ||
|
||
const message = {stage: null} as IntakeMessage; | ||
const userPre = {quests: {QuestMousoleum: {has_wall: false}}} as User; | ||
const userPost = {} as User; | ||
const journal = {}; | ||
stager.addStage(message, userPre, userPost, journal); | ||
expect(message.stage).toBe('No Wall'); | ||
}); | ||
|
||
it('throws an error if QuestMousoleum is undefined', () => { | ||
const stager = new MousoleumStager(); | ||
|
||
const message = {stage: null} as IntakeMessage; | ||
const userPre = {quests: {}} as User; | ||
const userPost = {} as User; | ||
const journal = {}; | ||
expect(() => { | ||
stager.addStage(message, userPre, userPost, journal); | ||
}).toThrowError('QuestMousoleum is undefined'); | ||
}); | ||
}); |