From 007d862523d17b09822347b4ac0259b9545084c2 Mon Sep 17 00:00:00 2001 From: bjoluc Date: Wed, 6 Dec 2023 20:00:29 +0100 Subject: [PATCH] Add a `getResult[s]()` unit test for the `record_data: false` parameter --- packages/jspsych/src/timeline/Trial.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/jspsych/src/timeline/Trial.spec.ts b/packages/jspsych/src/timeline/Trial.spec.ts index e763948e64..e92aa2f9cb 100644 --- a/packages/jspsych/src/timeline/Trial.spec.ts +++ b/packages/jspsych/src/timeline/Trial.spec.ts @@ -704,6 +704,20 @@ describe("Trial", () => { expect(trial.getResult()).toEqual(expect.objectContaining({ my: "result" })); expect(trial.getResults()).toEqual([expect.objectContaining({ my: "result" })]); }); + + it("does not return the result when the `record_data` trial parameter is `false`", async () => { + TestPlugin.setManualFinishTrialMode(); + const trial = createTrial({ type: TestPlugin, record_data: false }); + trial.run(); + + expect(trial.getResult()).toBeUndefined(); + expect(trial.getResults()).toEqual([]); + + await TestPlugin.finishTrial(); + + expect(trial.getResult()).toBeUndefined(); + expect(trial.getResults()).toEqual([]); + }); }); describe("evaluateTimelineVariable()", () => {