Skip to content

Commit

Permalink
Fixed tests by adding version to ignored fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhang03 committed Jun 25, 2024
1 parent c5a0dbb commit b7bd08a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
16 changes: 12 additions & 4 deletions packages/jspsych/tests/data/data-csv-conversion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe("data conversion to csv", () => {

await clickTarget(document.querySelector("#jspsych-survey-text-next"));

expect(getData().ignore(["rt", "internal_node_id", "time_elapsed", "trial_type"]).csv()).toBe(
'"response","trial_index"\r\n"{""Q0"":""Response 1"",""Q1"":""Response 2""}","0"\r\n'
);
expect(
getData().ignore(["rt", "internal_node_id", "time_elapsed", "trial_type", "version"]).csv()
).toBe('"response","trial_index"\r\n"{""Q0"":""Response 1"",""Q1"":""Response 2""}","0"\r\n');
});

test("same-different-html stimulus array is correctly converted", async () => {
Expand Down Expand Up @@ -51,6 +51,7 @@ describe("data conversion to csv", () => {
"trial_type",
"rt_stim1",
"response_stim1",
"version",
])
.csv()
).toBe(
Expand All @@ -74,7 +75,14 @@ describe("data conversion to csv", () => {

expect(
getData()
.ignore(["rt", "internal_node_id", "time_elapsed", "trial_type", "question_order"])
.ignore([
"rt",
"internal_node_id",
"time_elapsed",
"trial_type",
"question_order",
"version",
])
.csv()
).toBe('"response","trial_index"\r\n"{""q"":[""fuzz"",""bizz""]}","0"\r\n');
});
Expand Down
16 changes: 12 additions & 4 deletions packages/jspsych/tests/data/data-json-conversion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ describe("data conversion to json", () => {

await clickTarget(document.querySelector("#jspsych-survey-text-next"));

expect(getData().ignore(["rt", "internal_node_id", "time_elapsed", "trial_type"]).json()).toBe(
JSON.stringify([{ response: { Q0: "Response 1", Q1: "Response 2" }, trial_index: 0 }])
);
expect(
getData().ignore(["rt", "internal_node_id", "time_elapsed", "trial_type", "version"]).json()
).toBe(JSON.stringify([{ response: { Q0: "Response 1", Q1: "Response 2" }, trial_index: 0 }]));
});

test("same-different-html stimulus array is correctly converted", async () => {
Expand Down Expand Up @@ -52,6 +52,7 @@ describe("data conversion to json", () => {
"trial_type",
"rt_stim1",
"response_stim1",
"version",
])
.json()
).toBe(
Expand Down Expand Up @@ -83,7 +84,14 @@ describe("data conversion to json", () => {

expect(
getData()
.ignore(["rt", "internal_node_id", "time_elapsed", "trial_type", "question_order"])
.ignore([
"rt",
"internal_node_id",
"time_elapsed",
"trial_type",
"question_order",
"version",
])
.json()
).toBe(
JSON.stringify([
Expand Down
2 changes: 1 addition & 1 deletion packages/jspsych/tests/data/datamodule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("#displayData", () => {
jsPsych.data.displayData("csv");
// check display element HTML
expect(getHTML()).toMatch(
/<pre id="jspsych-data-display">"rt","stimulus","response","trial_type","trial_index","time_elapsed"\r\n"[\d]+","hello","a","html-keyboard-response","0","[\d]+"\r\n<\/pre>/
/<pre id="jspsych-data-display">"rt","stimulus","response","trial_type","trial_index","version","time_elapsed"\r\n"[\d]+","hello","a","html-keyboard-response","0","[\d.]+","[\d]+"\r\n<\/pre>/
);
});
});

0 comments on commit b7bd08a

Please sign in to comment.