Re-enable tests that depend on plugins converted in #2078

This commit is contained in:
bjoluc 2021-09-14 18:31:48 +02:00
parent 7fa8f26325
commit 63acb56dac
6 changed files with 40 additions and 56 deletions

View File

@ -1,12 +1,11 @@
// import surveyText from "@jspsych/plugin-survey-text"; import surveyText from "@jspsych/plugin-survey-text";
import { startTimeline } from "../utils"; import { startTimeline } from "../utils";
describe("nested defaults", () => { describe("nested defaults", () => {
test.skip("work in basic situation", async () => { test("work in basic situation", async () => {
const { displayElement } = await startTimeline([ const { displayElement } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: [ questions: [
{ {
@ -23,14 +22,13 @@ describe("nested defaults", () => {
expect(displayElement.querySelector("input").size).toBe(40); expect(displayElement.querySelector("input").size).toBe(40);
}); });
test.skip("safe against extending the array.prototype (issue #989)", async () => { test("safe against extending the array.prototype (issue #989)", async () => {
// @ts-expect-error // @ts-expect-error
Array.prototype.qq = jest.fn(); Array.prototype.qq = jest.fn();
const spy = jest.spyOn(console, "error").mockImplementation(); const spy = jest.spyOn(console, "error").mockImplementation();
const { displayElement } = await startTimeline([ const { displayElement } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: [ questions: [
{ {

View File

@ -1,9 +1,10 @@
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response"; import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import htmlSliderResponse from "@jspsych/plugin-html-slider-response";
import { initJsPsych } from "../../src"; import { initJsPsych } from "../../src";
import { pressKey, startTimeline } from "../utils"; import { pressKey, startTimeline } from "../utils";
// import htmlSliderResponse from "@jspsych/plugin-html-slider-response"; jest.useFakeTimers();
describe("on_finish (trial)", () => { describe("on_finish (trial)", () => {
test("should get an object of data generated by the trial", async () => { test("should get an object of data generated by the trial", async () => {
@ -151,13 +152,11 @@ describe("on_data_update", () => {
expect(key).toBe("a"); expect(key).toBe("a");
}); });
test.skip("should contain data with null values", async () => { test("should contain data with null values", async () => {
const data = []; const onDataUpdateFn = jest.fn();
const jsPsych = initJsPsych({ const jsPsych = initJsPsych({
on_data_update: (data) => { on_data_update: onDataUpdateFn,
data.push(data);
},
}); });
await startTimeline( await startTimeline(
[ [
@ -167,7 +166,6 @@ describe("on_data_update", () => {
trial_duration: 10, trial_duration: 10,
}, },
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: htmlSliderResponse, type: htmlSliderResponse,
stimulus: "hello", stimulus: "hello",
trial_duration: 10, trial_duration: 10,
@ -176,10 +174,13 @@ describe("on_data_update", () => {
jsPsych jsPsych
); );
expect(data[0].response).not.toBeUndefined(); jest.advanceTimersByTime(20);
expect(data[0].response).toBeNull();
expect(data[1].response).toBeNull(); expect(onDataUpdateFn).toHaveBeenNthCalledWith(1, expect.objectContaining({ response: null }));
expect(data[1].rt).toBeNull(); expect(onDataUpdateFn).toHaveBeenNthCalledWith(
2,
expect.objectContaining({ response: null, rt: null })
);
}); });
test("should contain data added with on_finish (trial level)", async () => { test("should contain data added with on_finish (trial level)", async () => {

View File

@ -1,12 +1,11 @@
// import cloze from "@jspsych/plugin-cloze"; import cloze from "@jspsych/plugin-cloze";
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response"; import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import surveyMultiChoice from "@jspsych/plugin-survey-multi-choice";
import surveyText from "@jspsych/plugin-survey-text";
import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "../../src"; import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "../../src";
import { clickTarget, pressKey, startTimeline } from "../utils"; import { clickTarget, pressKey, startTimeline } from "../utils";
// import surveyMultiChoice from "@jspsych/plugin-survey-multi-choice";
// import surveyText from "@jspsych/plugin-survey-text";
describe("standard use of function as parameter", () => { describe("standard use of function as parameter", () => {
test("function value is used as parameter", async () => { test("function value is used as parameter", async () => {
const { getHTML } = await startTimeline([ const { getHTML } = await startTimeline([
@ -20,12 +19,11 @@ describe("standard use of function as parameter", () => {
pressKey("a"); pressKey("a");
}); });
test.skip("parameters can be protected from early evaluation using ParameterType.FUNCTION", async () => { test("parameters can be protected from early evaluation using ParameterType.FUNCTION", async () => {
var mock = jest.fn(); var mock = jest.fn();
await startTimeline([ await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: cloze, type: cloze,
text: "%foo%", text: "%foo%",
check_answers: true, check_answers: true,
@ -70,10 +68,9 @@ describe("data as function", () => {
}); });
describe("nested parameters as functions", () => { describe("nested parameters as functions", () => {
test.skip("entire parameter can be a function", async () => { test("entire parameter can be a function", async () => {
const { displayElement, expectFinished } = await startTimeline([ const { displayElement, expectFinished } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: () => [{ prompt: "How old are you?" }, { prompt: "Where were you born?" }], questions: () => [{ prompt: "How old are you?" }, { prompt: "Where were you born?" }],
}, },
@ -84,10 +81,9 @@ describe("nested parameters as functions", () => {
await expectFinished(); await expectFinished();
}); });
test.skip("nested parameter can be a function", async () => { test("nested parameter can be a function", async () => {
const { expectFinished } = await startTimeline([ const { expectFinished } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: [ questions: [
{ {
@ -110,10 +106,9 @@ describe("nested parameters as functions", () => {
await expectFinished(); await expectFinished();
}); });
test.skip("multiple nested parameters can be functions", async () => { test("multiple nested parameters can be functions", async () => {
const { expectFinished } = await startTimeline([ const { expectFinished } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiChoice, type: surveyMultiChoice,
questions: [ questions: [
{ {

View File

@ -1,16 +1,15 @@
// import sameDifferentHtml from "@jspsych/plugin-same-different-html"; import sameDifferentHtml from "@jspsych/plugin-same-different-html";
// import surveyMultiSelect from "@jspsych/plugin-survey-multi-select"; import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
// import surveyText from "@jspsych/plugin-survey-text"; import surveyText from "@jspsych/plugin-survey-text";
import { clickTarget, pressKey, startTimeline } from "../utils"; import { clickTarget, pressKey, startTimeline } from "../utils";
jest.useFakeTimers(); jest.useFakeTimers();
describe("data conversion to csv", () => { describe("data conversion to csv", () => {
test.skip("survey-text data response object is correctly converted", async () => { test("survey-text data response object is correctly converted", async () => {
const { getData } = await startTimeline([ const { getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: [{ prompt: "Q1" }, { prompt: "Q2" }], questions: [{ prompt: "Q1" }, { prompt: "Q2" }],
}, },
@ -26,10 +25,9 @@ describe("data conversion to csv", () => {
); );
}); });
test.skip("same-different-html stimulus array is correctly converted", async () => { test("same-different-html stimulus array is correctly converted", async () => {
const { getHTML, getData } = await startTimeline([ const { getHTML, getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: sameDifferentHtml, type: sameDifferentHtml,
stimuli: ["<p>Climbing</p>", "<p>Walking</p>"], stimuli: ["<p>Climbing</p>", "<p>Walking</p>"],
answer: "different", answer: "different",
@ -61,10 +59,9 @@ describe("data conversion to csv", () => {
); );
}); });
test.skip("survey-multi-select response array is correctly converted", async () => { test("survey-multi-select response array is correctly converted", async () => {
const { getHTML, getData } = await startTimeline([ const { getHTML, getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiSelect, type: surveyMultiSelect,
questions: [{ prompt: "foo", options: ["fuzz", "bizz", "bar"], name: "q" }], questions: [{ prompt: "foo", options: ["fuzz", "bizz", "bar"], name: "q" }],
}, },

View File

@ -1,17 +1,16 @@
// import instructions from "@jspsych/plugin-instructions"; import instructions from "@jspsych/plugin-instructions";
// import sameDifferentHtml from "@jspsych/plugin-same-different-html"; import sameDifferentHtml from "@jspsych/plugin-same-different-html";
// import surveyMultiSelect from "@jspsych/plugin-survey-multi-select"; import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
// import surveyText from "@jspsych/plugin-survey-text"; import surveyText from "@jspsych/plugin-survey-text";
import { clickTarget, pressKey, startTimeline } from "../utils"; import { clickTarget, pressKey, startTimeline } from "../utils";
jest.useFakeTimers(); jest.useFakeTimers();
describe("data conversion to json", () => { describe("data conversion to json", () => {
test.skip("survey-text data response object is correctly converted", async () => { test("survey-text data response object is correctly converted", async () => {
const { getData } = await startTimeline([ const { getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText, type: surveyText,
questions: [{ prompt: "Q1" }, { prompt: "Q2" }], questions: [{ prompt: "Q1" }, { prompt: "Q2" }],
}, },
@ -27,10 +26,9 @@ describe("data conversion to json", () => {
); );
}); });
test.skip("same-different-html stimulus array is correctly converted", async () => { test("same-different-html stimulus array is correctly converted", async () => {
const { getHTML, getData } = await startTimeline([ const { getHTML, getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: sameDifferentHtml, type: sameDifferentHtml,
stimuli: ["<p>Climbing</p>", "<p>Walking</p>"], stimuli: ["<p>Climbing</p>", "<p>Walking</p>"],
answer: "different", answer: "different",
@ -70,10 +68,9 @@ describe("data conversion to json", () => {
); );
}); });
test.skip("survey-multi-select response array is correctly converted", async () => { test("survey-multi-select response array is correctly converted", async () => {
const { getHTML, getData } = await startTimeline([ const { getHTML, getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiSelect, type: surveyMultiSelect,
questions: [{ prompt: "foo", options: ["fuzz", "bizz", "bar"], name: "q" }], questions: [{ prompt: "foo", options: ["fuzz", "bizz", "bar"], name: "q" }],
}, },
@ -101,10 +98,9 @@ describe("data conversion to json", () => {
); );
}); });
test.skip("instructions view_history is correctly converted - issue #670", async () => { test("instructions view_history is correctly converted - issue #670", async () => {
const { getHTML, getData } = await startTimeline([ const { getHTML, getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once the plugin is a class
type: instructions, type: instructions,
pages: ["page 1", "page 2"], pages: ["page 1", "page 2"],
key_forward: "a", key_forward: "a",

View File

@ -1,10 +1,9 @@
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response"; import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import reconstruction from "@jspsych/plugin-reconstruction";
import surveyText from "@jspsych/plugin-survey-text";
import { clickTarget, pressKey, startTimeline } from "../utils"; import { clickTarget, pressKey, startTimeline } from "../utils";
// import reconstruction from "@jspsych/plugin-reconstruction";
// import surveyText from "@jspsych/plugin-survey-text";
describe("Trial parameters in the data", () => { describe("Trial parameters in the data", () => {
test("Can be added by specifying the parameter with a value of true in save_trial_parameters", async () => { test("Can be added by specifying the parameter with a value of true in save_trial_parameters", async () => {
const { getData } = await startTimeline([ const { getData } = await startTimeline([
@ -81,12 +80,11 @@ describe("Trial parameters in the data", () => {
spy.mockRestore(); spy.mockRestore();
}); });
test.skip("Arrayed objects work with save_trial_parameters ", async () => { test("Arrayed objects work with save_trial_parameters ", async () => {
const questions = [{ prompt: "foo" }, { prompt: "bar" }]; const questions = [{ prompt: "foo" }, { prompt: "bar" }];
const { getData } = await startTimeline([ const { getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once surveyText is a class
type: surveyText, type: surveyText,
questions, questions,
save_trial_parameters: { save_trial_parameters: {
@ -102,7 +100,7 @@ describe("Trial parameters in the data", () => {
expect(data.questions[1].prompt).toBe(questions[1].prompt); expect(data.questions[1].prompt).toBe(questions[1].prompt);
}); });
test.skip("Function-based parameters are stored as string representations ", async () => { test("Function-based parameters are stored as string representations ", async () => {
const sample_function = (param) => { const sample_function = (param) => {
var size = 50 + Math.floor(param * 250); var size = 50 + Math.floor(param * 250);
var html = var html =
@ -118,7 +116,6 @@ describe("Trial parameters in the data", () => {
const { getData } = await startTimeline([ const { getData } = await startTimeline([
{ {
// @ts-ignore TODO enable this test once reconstruction is a class
type: reconstruction, type: reconstruction,
stim_function: sample_function, stim_function: sample_function,
starting_value: 0.25, starting_value: 0.25,