From 66016334cfe39a5ff2af6cb220719c4fbcc594c3 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 12 Jun 2024 08:56:36 -0400 Subject: [PATCH] Fix: get_output_value without a successful previous run. (#334) Signed-off-by: dblock --- tools/src/tester/StoryOutputs.ts | 3 ++- tools/tests/tester/story_outputs.test.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/src/tester/StoryOutputs.ts b/tools/src/tester/StoryOutputs.ts index ab06f3733..afff24d96 100644 --- a/tools/src/tester/StoryOutputs.ts +++ b/tools/src/tester/StoryOutputs.ts @@ -31,7 +31,8 @@ export class StoryOutputs { } get_output_value (chapter_id: string, output_name: string): any { - return this.outputs[chapter_id].get_output(output_name) + const output = this.outputs[chapter_id] + return output !== undefined ? output.get_output(output_name) : undefined } resolve_params (parameters: Record): Record { diff --git a/tools/tests/tester/story_outputs.test.ts b/tools/tests/tester/story_outputs.test.ts index 2f06f89c4..23acc68a1 100644 --- a/tools/tests/tester/story_outputs.test.ts +++ b/tools/tests/tester/story_outputs.test.ts @@ -19,6 +19,7 @@ const story_outputs = new StoryOutputs({ test('resolve_string', () => { expect(story_outputs.resolve_string('${chapter_id.x}')).toEqual(1) + expect(story_outputs.resolve_string('${invalid_id.x}')).toBeUndefined() expect(story_outputs.resolve_string('some_str')).toEqual('some_str') })