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";
describe("nested defaults", () => {
test.skip("work in basic situation", async () => {
test("work in basic situation", async () => {
const { displayElement } = await startTimeline([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
questions: [
{
@ -23,14 +22,13 @@ describe("nested defaults", () => {
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
Array.prototype.qq = jest.fn();
const spy = jest.spyOn(console, "error").mockImplementation();
const { displayElement } = await startTimeline([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
questions: [
{

View File

@ -1,9 +1,10 @@
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import htmlSliderResponse from "@jspsych/plugin-html-slider-response";
import { initJsPsych } from "../../src";
import { pressKey, startTimeline } from "../utils";
// import htmlSliderResponse from "@jspsych/plugin-html-slider-response";
jest.useFakeTimers();
describe("on_finish (trial)", () => {
test("should get an object of data generated by the trial", async () => {
@ -151,13 +152,11 @@ describe("on_data_update", () => {
expect(key).toBe("a");
});
test.skip("should contain data with null values", async () => {
const data = [];
test("should contain data with null values", async () => {
const onDataUpdateFn = jest.fn();
const jsPsych = initJsPsych({
on_data_update: (data) => {
data.push(data);
},
on_data_update: onDataUpdateFn,
});
await startTimeline(
[
@ -167,7 +166,6 @@ describe("on_data_update", () => {
trial_duration: 10,
},
{
// @ts-ignore TODO enable this test once the plugin is a class
type: htmlSliderResponse,
stimulus: "hello",
trial_duration: 10,
@ -176,10 +174,13 @@ describe("on_data_update", () => {
jsPsych
);
expect(data[0].response).not.toBeUndefined();
expect(data[0].response).toBeNull();
expect(data[1].response).toBeNull();
expect(data[1].rt).toBeNull();
jest.advanceTimersByTime(20);
expect(onDataUpdateFn).toHaveBeenNthCalledWith(1, expect.objectContaining({ response: null }));
expect(onDataUpdateFn).toHaveBeenNthCalledWith(
2,
expect.objectContaining({ response: null, rt: null })
);
});
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 surveyMultiChoice from "@jspsych/plugin-survey-multi-choice";
import surveyText from "@jspsych/plugin-survey-text";
import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "../../src";
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", () => {
test("function value is used as parameter", async () => {
const { getHTML } = await startTimeline([
@ -20,12 +19,11 @@ describe("standard use of function as parameter", () => {
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();
await startTimeline([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: cloze,
text: "%foo%",
check_answers: true,
@ -70,10 +68,9 @@ describe("data as function", () => {
});
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
questions: () => [{ prompt: "How old are you?" }, { prompt: "Where were you born?" }],
},
@ -84,10 +81,9 @@ describe("nested parameters as functions", () => {
await expectFinished();
});
test.skip("nested parameter can be a function", async () => {
test("nested parameter can be a function", async () => {
const { expectFinished } = await startTimeline([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
questions: [
{
@ -110,10 +106,9 @@ describe("nested parameters as functions", () => {
await expectFinished();
});
test.skip("multiple nested parameters can be functions", async () => {
test("multiple nested parameters can be functions", async () => {
const { expectFinished } = await startTimeline([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiChoice,
questions: [
{

View File

@ -1,16 +1,15 @@
// import sameDifferentHtml from "@jspsych/plugin-same-different-html";
// import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
// import surveyText from "@jspsych/plugin-survey-text";
import sameDifferentHtml from "@jspsych/plugin-same-different-html";
import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
import surveyText from "@jspsych/plugin-survey-text";
import { clickTarget, pressKey, startTimeline } from "../utils";
jest.useFakeTimers();
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: sameDifferentHtml,
stimuli: ["<p>Climbing</p>", "<p>Walking</p>"],
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiSelect,
questions: [{ prompt: "foo", options: ["fuzz", "bizz", "bar"], name: "q" }],
},

View File

@ -1,17 +1,16 @@
// import instructions from "@jspsych/plugin-instructions";
// import sameDifferentHtml from "@jspsych/plugin-same-different-html";
// import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
// import surveyText from "@jspsych/plugin-survey-text";
import instructions from "@jspsych/plugin-instructions";
import sameDifferentHtml from "@jspsych/plugin-same-different-html";
import surveyMultiSelect from "@jspsych/plugin-survey-multi-select";
import surveyText from "@jspsych/plugin-survey-text";
import { clickTarget, pressKey, startTimeline } from "../utils";
jest.useFakeTimers();
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyText,
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: sameDifferentHtml,
stimuli: ["<p>Climbing</p>", "<p>Walking</p>"],
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: surveyMultiSelect,
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([
{
// @ts-ignore TODO enable this test once the plugin is a class
type: instructions,
pages: ["page 1", "page 2"],
key_forward: "a",

View File

@ -1,10 +1,9 @@
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 reconstruction from "@jspsych/plugin-reconstruction";
// import surveyText from "@jspsych/plugin-survey-text";
describe("Trial parameters in the data", () => {
test("Can be added by specifying the parameter with a value of true in save_trial_parameters", async () => {
const { getData } = await startTimeline([
@ -81,12 +80,11 @@ describe("Trial parameters in the data", () => {
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 { getData } = await startTimeline([
{
// @ts-ignore TODO enable this test once surveyText is a class
type: surveyText,
questions,
save_trial_parameters: {
@ -102,7 +100,7 @@ describe("Trial parameters in the data", () => {
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) => {
var size = 50 + Math.floor(param * 250);
var html =
@ -118,7 +116,6 @@ describe("Trial parameters in the data", () => {
const { getData } = await startTimeline([
{
// @ts-ignore TODO enable this test once reconstruction is a class
type: reconstruction,
stim_function: sample_function,
starting_value: 0.25,