Skip to content

Commit

Permalink
Fix issue with print_stack mock.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Jun 21, 2023
1 parent c8050d6 commit 9a0737d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/engine/core/utils/assertion.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { describe, expect, it } from "@jest/globals";
import { print_stack } from "xray16";

import { abort, assert, assertBoolean, assertDefined } from "@/engine/core/utils/assertion";

describe("'debug' utils", () => {
it("'abort' should correctly throw exceptions", () => {
expect(() => abort("Basic.")).toThrow("Basic.");
expect(print_stack).toHaveBeenCalledTimes(1);

expect(() => abort("Basic: '%s'.", "reason")).toThrow("Basic: 'reason'.");
expect(print_stack).toHaveBeenCalledTimes(2);

expect(() => abort("Complex: '%s', '%s', '%s'.", "reason", 1, true)).toThrow("Complex: 'reason', '1', 'true'.");
expect(print_stack).toHaveBeenCalledTimes(3);
});

it("'assert' should correctly check and throw exceptions", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/fixtures/xray/mockXRay16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function mockXRay16({
patrol = MockPatrol,
property_evaluator = MockPropertyEvaluator,
property_storage = MockPropertyStorage,
print_stack = jest.fn(),
relation_registry = mockRelationRegistryInterface,
sound_object = MockSoundObject,
sight_params = MockSightParameters,
Expand Down Expand Up @@ -224,6 +225,7 @@ export function mockXRay16({
patrol,
property_evaluator,
property_storage,
print_stack,
relation_registry,
sound_object,
sight_params,
Expand Down

0 comments on commit 9a0737d

Please sign in to comment.