From 5837568c2b387156bcddfbaf220bbb1166e41cb4 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Mon, 3 Jun 2024 13:51:23 -0400 Subject: [PATCH] ensure that null values are allowed, even when there is a default --- packages/jspsych/src/timeline/Trial.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/jspsych/src/timeline/Trial.spec.ts b/packages/jspsych/src/timeline/Trial.spec.ts index 0a3dda8769..04fdad9f79 100644 --- a/packages/jspsych/src/timeline/Trial.spec.ts +++ b/packages/jspsych/src/timeline/Trial.spec.ts @@ -462,6 +462,21 @@ describe("Trial", () => { ); }); + it("allows null values for parameters with a non-null default value", async () => { + TestPlugin.setParameterInfos({ + allowedNullString: { type: ParameterType.STRING, default: "foo" }, + }); + + const trial = createTrial({ type: TestPlugin, allowedNullString: null }); + await trial.run(); + + expect(trial.pluginInstance.trial).toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ allowedNullString: null }), + expect.anything() + ); + }); + describe("with missing required parameters", () => { it("errors on missing simple parameters", async () => { TestPlugin.setParameterInfos({ requiredString: { type: ParameterType.STRING } });