Skip to content

Commit

Permalink
test(state): Exception check tests for GameInstanceImpl.revert
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Nov 29, 2018
1 parent 918c310 commit 5b44904
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/unit/game-instance.test.ts
Expand Up @@ -250,7 +250,7 @@ describe("GameInstance", function() {
const myGame = buildGameInstance({ trackAgentChanges: true });
first.then(second)(myGame);

expect(myGame.state.arr).to.deep.equal([1, 2, 3, 4, 5, 6]);
expect(myGame.state.arr).to.deep.equal([1, 2, 3, 4, 5, 6]); // Precondition
expect(myGame.state.arr.length).to.equal(6);

const revGame = myGame.revert(1);
Expand Down Expand Up @@ -335,5 +335,20 @@ describe("GameInstance", function() {
nq(atk, atk, atk, atk)(revGame);
expect(revGame.state.dummy.health).to.equal(62);
});

it("Throw an error if given a revertTo arg less than zero", function() {
expect(() => buildGameInstance().revert(-1)).to.throw(
RegalError,
"revertTo must be zero or greater."
);
});

it("Throw an error if revertTo is nonzero when trackAgentChanges is disabled", function() {
const myGame = buildGameInstance({ trackAgentChanges: false });
expect(() => myGame.revert(1)).to.throw(
RegalError,
"In order to revert to an intermediate event ID, GameOptions.trackAgentChanges must be true."
);
});
});
});

0 comments on commit 5b44904

Please sign in to comment.