Skip to content

Commit

Permalink
ensure that null values are allowed, even when there is a default
Browse files Browse the repository at this point in the history
  • Loading branch information
jodeleeuw committed Jun 3, 2024
1 parent 233deb6 commit 5837568
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/jspsych/src/timeline/Trial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down

0 comments on commit 5837568

Please sign in to comment.