From 05d59d1c8821e36d0baad8361d7f3b10ea8555e9 Mon Sep 17 00:00:00 2001 From: bjoluc Date: Sat, 12 Oct 2024 20:44:55 +0200 Subject: [PATCH] Add test case for #3412 --- packages/jspsych/src/timeline/Trial.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/jspsych/src/timeline/Trial.spec.ts b/packages/jspsych/src/timeline/Trial.spec.ts index 04fdad9f79..2d3a125666 100644 --- a/packages/jspsych/src/timeline/Trial.spec.ts +++ b/packages/jspsych/src/timeline/Trial.spec.ts @@ -387,6 +387,7 @@ describe("Trial", () => { // This should work: await createTrial({ type: TestPlugin, stringArray: [] }).run(); + await createTrial({ type: TestPlugin, stringArray: new TimelineVariable("a") }); // This shouldn't: await expect( @@ -436,6 +437,8 @@ describe("Trial", () => { return TestPlugin; case "x": return "foo"; + case "y": + return ["foo", "bar"]; default: return undefined; } @@ -444,17 +447,19 @@ describe("Trial", () => { const trial = createTrial({ type: new TimelineVariable("t"), requiredString: new TimelineVariable("x"), + stringArray: new TimelineVariable("y"), requiredComplexNested: { requiredChild: () => new TimelineVariable("x") }, requiredComplexNestedArray: [{ requiredChild: () => new TimelineVariable("x") }], }); await trial.run(); - // The `x` timeline variables should have been replaced with `foo` + // The `x` and `y` timeline variables should have been evaluated expect(trial.pluginInstance.trial).toHaveBeenCalledWith( expect.anything(), expect.objectContaining({ requiredString: "foo", + stringArray: ["foo", "bar"], requiredComplexNested: expect.objectContaining({ requiredChild: "foo" }), requiredComplexNestedArray: [expect.objectContaining({ requiredChild: "foo" })], }),