Skip to content

Commit

Permalink
Add test case for #3412 (#3416)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoluc authored Dec 1, 2024
1 parent d848270 commit b9fd35a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/jspsych/src/timeline/Trial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ describe("Trial", () => {
return TestPlugin;
case "x":
return "foo";
case "y":
return ["foo", "bar"];
default:
return undefined;
}
Expand All @@ -444,17 +446,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" })],
}),
Expand Down

0 comments on commit b9fd35a

Please sign in to comment.