Skip to content

Commit

Permalink
Merge pull request jspsych#3304 from jspsych/v8-null-default-test
Browse files Browse the repository at this point in the history
Add a test case for trial parameters with `null` values
  • Loading branch information
jodeleeuw authored Jun 6, 2024
2 parents 233deb6 + 5837568 commit 505be4b
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 505be4b

Please sign in to comment.