jspsych 6.3.1 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -37
- package/css/jspsych.css +39 -39
- package/dist/JsPsych.d.ts +112 -0
- package/dist/TimelineNode.d.ts +34 -0
- package/dist/index.browser.js +3171 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.browser.min.js +2 -0
- package/dist/index.browser.min.js.map +1 -0
- package/dist/index.cjs +3165 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3159 -0
- package/dist/index.js.map +1 -0
- package/dist/migration.d.ts +3 -0
- package/dist/modules/data/DataCollection.d.ts +45 -0
- package/dist/modules/data/DataColumn.d.ts +15 -0
- package/dist/modules/data/index.d.ts +25 -0
- package/dist/modules/data/utils.d.ts +3 -0
- package/dist/modules/extensions.d.ts +22 -0
- package/dist/modules/plugin-api/HardwareAPI.d.ts +15 -0
- package/dist/modules/plugin-api/KeyboardListenerAPI.d.ts +34 -0
- package/dist/modules/plugin-api/MediaAPI.d.ts +27 -0
- package/dist/modules/plugin-api/SimulationAPI.d.ts +41 -0
- package/dist/modules/plugin-api/TimeoutAPI.d.ts +5 -0
- package/dist/modules/plugin-api/index.d.ts +8 -0
- package/dist/modules/plugins.d.ts +136 -0
- package/dist/modules/randomization.d.ts +35 -0
- package/dist/modules/turk.d.ts +40 -0
- package/dist/modules/utils.d.ts +7 -0
- package/package.json +32 -15
- package/src/JsPsych.ts +884 -0
- package/src/TimelineNode.ts +536 -0
- package/src/index.ts +71 -0
- package/src/migration.ts +37 -0
- package/src/modules/data/DataCollection.ts +198 -0
- package/src/modules/data/DataColumn.ts +86 -0
- package/src/modules/data/index.ts +174 -0
- package/src/modules/data/utils.ts +75 -0
- package/src/modules/extensions.ts +23 -0
- package/src/modules/plugin-api/HardwareAPI.ts +32 -0
- package/src/modules/plugin-api/KeyboardListenerAPI.ts +165 -0
- package/src/modules/plugin-api/MediaAPI.ts +337 -0
- package/src/modules/plugin-api/SimulationAPI.ts +181 -0
- package/src/modules/plugin-api/TimeoutAPI.ts +16 -0
- package/src/modules/plugin-api/index.ts +28 -0
- package/src/modules/plugins.ts +165 -0
- package/src/modules/randomization.ts +327 -0
- package/src/modules/turk.ts +99 -0
- package/src/modules/utils.ts +30 -0
- package/.github/workflows/jest.yml +0 -20
- package/code-of-conduct.md +0 -56
- package/contributors.md +0 -61
- package/docs/CNAME +0 -1
- package/docs/about/about.md +0 -18
- package/docs/about/contributing.md +0 -43
- package/docs/about/license.md +0 -25
- package/docs/about/support.md +0 -7
- package/docs/core_library/jspsych-core.md +0 -719
- package/docs/core_library/jspsych-data.md +0 -587
- package/docs/core_library/jspsych-pluginAPI.md +0 -624
- package/docs/core_library/jspsych-randomization.md +0 -389
- package/docs/core_library/jspsych-turk.md +0 -98
- package/docs/extensions/extensions.md +0 -83
- package/docs/extensions/jspsych-ext-webgazer.md +0 -137
- package/docs/img/blue.png +0 -0
- package/docs/img/devtools-change-css.png +0 -0
- package/docs/img/devtools-css-errors.png +0 -0
- package/docs/img/devtools-inspect-element.png +0 -0
- package/docs/img/folder-setup.png +0 -0
- package/docs/img/folder-with-html.png +0 -0
- package/docs/img/githubreleases.jpg +0 -0
- package/docs/img/jspsych-favicon.png +0 -0
- package/docs/img/jspsych-logo-no-text-mono.svg +0 -493
- package/docs/img/jspsych-logo.jpg +0 -0
- package/docs/img/orange.png +0 -0
- package/docs/img/palmer_stim.png +0 -0
- package/docs/img/progress_bar.png +0 -0
- package/docs/img/prolific-study-completion.png +0 -0
- package/docs/img/prolific-study-link.png +0 -0
- package/docs/img/visual_search_example.jpg +0 -0
- package/docs/index.md +0 -9
- package/docs/overview/browser-device-support.md +0 -35
- package/docs/overview/callbacks.md +0 -180
- package/docs/overview/data.md +0 -281
- package/docs/overview/dynamic-parameters.md +0 -147
- package/docs/overview/exclude-browser.md +0 -32
- package/docs/overview/experiment-options.md +0 -149
- package/docs/overview/eye-tracking.md +0 -271
- package/docs/overview/fullscreen.md +0 -36
- package/docs/overview/media-preloading.md +0 -369
- package/docs/overview/mturk.md +0 -77
- package/docs/overview/plugins.md +0 -320
- package/docs/overview/progress-bar.md +0 -110
- package/docs/overview/prolific.md +0 -78
- package/docs/overview/record-browser-interactions.md +0 -23
- package/docs/overview/running-experiments.md +0 -95
- package/docs/overview/style.md +0 -293
- package/docs/overview/timeline.md +0 -457
- package/docs/plugins/jspsych-animation.md +0 -40
- package/docs/plugins/jspsych-audio-button-response.md +0 -60
- package/docs/plugins/jspsych-audio-keyboard-response.md +0 -58
- package/docs/plugins/jspsych-audio-slider-response.md +0 -53
- package/docs/plugins/jspsych-call-function.md +0 -81
- package/docs/plugins/jspsych-canvas-button-response.md +0 -66
- package/docs/plugins/jspsych-canvas-keyboard-response.md +0 -68
- package/docs/plugins/jspsych-canvas-slider-response.md +0 -89
- package/docs/plugins/jspsych-categorize-animation.md +0 -60
- package/docs/plugins/jspsych-categorize-html.md +0 -53
- package/docs/plugins/jspsych-categorize-image.md +0 -53
- package/docs/plugins/jspsych-cloze.md +0 -45
- package/docs/plugins/jspsych-external-html.md +0 -70
- package/docs/plugins/jspsych-free-sort.md +0 -56
- package/docs/plugins/jspsych-fullscreen.md +0 -57
- package/docs/plugins/jspsych-html-button-response.md +0 -42
- package/docs/plugins/jspsych-html-keyboard-response.md +0 -51
- package/docs/plugins/jspsych-html-slider-response.md +0 -45
- package/docs/plugins/jspsych-iat-html.md +0 -64
- package/docs/plugins/jspsych-iat-image.md +0 -64
- package/docs/plugins/jspsych-image-button-response.md +0 -48
- package/docs/plugins/jspsych-image-keyboard-response.md +0 -58
- package/docs/plugins/jspsych-image-slider-response.md +0 -54
- package/docs/plugins/jspsych-instructions.md +0 -58
- package/docs/plugins/jspsych-maxdiff.md +0 -41
- package/docs/plugins/jspsych-preload.md +0 -128
- package/docs/plugins/jspsych-rdk.md +0 -119
- package/docs/plugins/jspsych-reconstruction.md +0 -48
- package/docs/plugins/jspsych-resize.md +0 -39
- package/docs/plugins/jspsych-same-different-html.md +0 -53
- package/docs/plugins/jspsych-same-different-image.md +0 -66
- package/docs/plugins/jspsych-serial-reaction-time-mouse.md +0 -52
- package/docs/plugins/jspsych-serial-reaction-time.md +0 -57
- package/docs/plugins/jspsych-survey-html-form.md +0 -50
- package/docs/plugins/jspsych-survey-likert.md +0 -70
- package/docs/plugins/jspsych-survey-multi-choice.md +0 -48
- package/docs/plugins/jspsych-survey-multi-select.md +0 -53
- package/docs/plugins/jspsych-survey-text.md +0 -63
- package/docs/plugins/jspsych-video-button-response.md +0 -54
- package/docs/plugins/jspsych-video-keyboard-response.md +0 -50
- package/docs/plugins/jspsych-video-slider-response.md +0 -60
- package/docs/plugins/jspsych-virtual-chinrest.md +0 -105
- package/docs/plugins/jspsych-visual-search-circle.md +0 -52
- package/docs/plugins/jspsych-vsl-animate-occlusion.md +0 -55
- package/docs/plugins/jspsych-vsl-grid-scene.md +0 -62
- package/docs/plugins/jspsych-webgazer-calibrate.md +0 -61
- package/docs/plugins/jspsych-webgazer-init-camera.md +0 -30
- package/docs/plugins/jspsych-webgazer-validate.md +0 -44
- package/docs/plugins/list-of-plugins.md +0 -54
- package/docs/tutorials/hello-world.md +0 -162
- package/docs/tutorials/rt-task.md +0 -1334
- package/docs/tutorials/video-tutorials.md +0 -11
- package/examples/add-to-end-of-timeline.html +0 -38
- package/examples/case-sensitive-responses.html +0 -45
- package/examples/conditional-and-loop-functions.html +0 -64
- package/examples/css/jquery-ui.css +0 -1225
- package/examples/css-classes-parameter.html +0 -145
- package/examples/data-add-properties.html +0 -44
- package/examples/data-as-function.html +0 -39
- package/examples/data-from-timeline.html +0 -52
- package/examples/data-from-url.html +0 -21
- package/examples/demo-flanker.html +0 -117
- package/examples/demo-simple-rt-task.html +0 -120
- package/examples/demos/demo_1.html +0 -35
- package/examples/demos/demo_2.html +0 -50
- package/examples/demos/demo_3.html +0 -63
- package/examples/display-element-to-embed-experiment.html +0 -79
- package/examples/end-active-node.html +0 -52
- package/examples/end-experiment.html +0 -45
- package/examples/exclusions.html +0 -32
- package/examples/external_html/simple_consent.html +0 -4
- package/examples/img/1.gif +0 -0
- package/examples/img/10.gif +0 -0
- package/examples/img/11.gif +0 -0
- package/examples/img/12.gif +0 -0
- package/examples/img/2.gif +0 -0
- package/examples/img/3.gif +0 -0
- package/examples/img/4.gif +0 -0
- package/examples/img/5.gif +0 -0
- package/examples/img/6.gif +0 -0
- package/examples/img/7.gif +0 -0
- package/examples/img/8.gif +0 -0
- package/examples/img/9.gif +0 -0
- package/examples/img/age/of1.jpg +0 -0
- package/examples/img/age/of2.jpg +0 -0
- package/examples/img/age/of3.jpg +0 -0
- package/examples/img/age/om1.jpg +0 -0
- package/examples/img/age/om2.jpg +0 -0
- package/examples/img/age/om3.jpg +0 -0
- package/examples/img/age/yf1.jpg +0 -0
- package/examples/img/age/yf4.jpg +0 -0
- package/examples/img/age/yf5.jpg +0 -0
- package/examples/img/age/ym2.jpg +0 -0
- package/examples/img/age/ym3.jpg +0 -0
- package/examples/img/age/ym5.jpg +0 -0
- package/examples/img/backwardN.gif +0 -0
- package/examples/img/blue.png +0 -0
- package/examples/img/card.png +0 -0
- package/examples/img/con1.png +0 -0
- package/examples/img/con2.png +0 -0
- package/examples/img/fixation.gif +0 -0
- package/examples/img/happy_face_1.jpg +0 -0
- package/examples/img/happy_face_2.jpg +0 -0
- package/examples/img/happy_face_3.jpg +0 -0
- package/examples/img/happy_face_4.jpg +0 -0
- package/examples/img/inc1.png +0 -0
- package/examples/img/inc2.png +0 -0
- package/examples/img/normalN.gif +0 -0
- package/examples/img/orange.png +0 -0
- package/examples/img/redX.png +0 -0
- package/examples/img/ribbon.jpg +0 -0
- package/examples/img/sad_face_1.jpg +0 -0
- package/examples/img/sad_face_2.jpg +0 -0
- package/examples/img/sad_face_3.jpg +0 -0
- package/examples/img/sad_face_4.jpg +0 -0
- package/examples/js/snap.svg-min.js +0 -21
- package/examples/js/webgazer/ridgeWorker.mjs +0 -135
- package/examples/js/webgazer/webgazer.js +0 -88909
- package/examples/js/webgazer/worker_scripts/mat.js +0 -306
- package/examples/js/webgazer/worker_scripts/util.js +0 -398
- package/examples/jspsych-RDK.html +0 -58
- package/examples/jspsych-animation.html +0 -39
- package/examples/jspsych-audio-button-response.html +0 -58
- package/examples/jspsych-audio-keyboard-response.html +0 -68
- package/examples/jspsych-audio-slider-response.html +0 -61
- package/examples/jspsych-call-function.html +0 -32
- package/examples/jspsych-canvas-button-response.html +0 -95
- package/examples/jspsych-canvas-keyboard-response.html +0 -78
- package/examples/jspsych-canvas-slider-response.html +0 -67
- package/examples/jspsych-categorize-animation.html +0 -49
- package/examples/jspsych-categorize-html.html +0 -33
- package/examples/jspsych-categorize-image.html +0 -44
- package/examples/jspsych-cloze.html +0 -37
- package/examples/jspsych-free-sort.html +0 -109
- package/examples/jspsych-fullscreen.html +0 -45
- package/examples/jspsych-html-button-response.html +0 -43
- package/examples/jspsych-html-keyboard-response.html +0 -42
- package/examples/jspsych-html-slider-response.html +0 -53
- package/examples/jspsych-iat.html +0 -520
- package/examples/jspsych-image-button-response.html +0 -91
- package/examples/jspsych-image-keyboard-response.html +0 -85
- package/examples/jspsych-image-slider-response.html +0 -85
- package/examples/jspsych-instructions.html +0 -37
- package/examples/jspsych-maxdiff.html +0 -33
- package/examples/jspsych-preload.html +0 -140
- package/examples/jspsych-reconstruction.html +0 -43
- package/examples/jspsych-resize.html +0 -34
- package/examples/jspsych-same-different-html.html +0 -28
- package/examples/jspsych-same-different-image.html +0 -39
- package/examples/jspsych-serial-reaction-time-mouse.html +0 -98
- package/examples/jspsych-serial-reaction-time.html +0 -54
- package/examples/jspsych-survey-html-form.html +0 -33
- package/examples/jspsych-survey-likert.html +0 -42
- package/examples/jspsych-survey-multi-choice.html +0 -40
- package/examples/jspsych-survey-multi-select.html +0 -42
- package/examples/jspsych-survey-text.html +0 -34
- package/examples/jspsych-video-button-response.html +0 -65
- package/examples/jspsych-video-keyboard-response.html +0 -61
- package/examples/jspsych-video-slider-response.html +0 -63
- package/examples/jspsych-virtual-chinrest.html +0 -69
- package/examples/jspsych-visual-search-circle.html +0 -64
- package/examples/jspsych-vsl-animate-occlusion.html +0 -35
- package/examples/jspsych-vsl-grid-scene.html +0 -47
- package/examples/lexical-decision.html +0 -134
- package/examples/manual-preloading.html +0 -59
- package/examples/pause-unpause.html +0 -33
- package/examples/progress-bar.html +0 -68
- package/examples/save-trial-parameters.html +0 -98
- package/examples/sound/hammer.mp3 +0 -0
- package/examples/sound/sound.mp3 +0 -0
- package/examples/sound/speech_blue.mp3 +0 -0
- package/examples/sound/speech_green.mp3 +0 -0
- package/examples/sound/speech_joke.mp3 +0 -0
- package/examples/sound/speech_red.mp3 +0 -0
- package/examples/sound/tone.mp3 +0 -0
- package/examples/timeline-variables-sampling.html +0 -50
- package/examples/timeline-variables.html +0 -64
- package/examples/video/sample_video.mp4 +0 -0
- package/examples/webgazer.html +0 -174
- package/examples/webgazer_audio.html +0 -90
- package/examples/webgazer_image.html +0 -60
- package/extensions/jspsych-ext-webgazer.js +0 -265
- package/jspsych.js +0 -3023
- package/license.txt +0 -21
- package/mkdocs.yml +0 -118
- package/plugins/jspsych-animation.js +0 -189
- package/plugins/jspsych-audio-button-response.js +0 -269
- package/plugins/jspsych-audio-keyboard-response.js +0 -209
- package/plugins/jspsych-audio-slider-response.js +0 -278
- package/plugins/jspsych-call-function.js +0 -58
- package/plugins/jspsych-canvas-button-response.js +0 -199
- package/plugins/jspsych-canvas-keyboard-response.js +0 -155
- package/plugins/jspsych-canvas-slider-response.js +0 -207
- package/plugins/jspsych-categorize-animation.js +0 -266
- package/plugins/jspsych-categorize-html.js +0 -220
- package/plugins/jspsych-categorize-image.js +0 -222
- package/plugins/jspsych-cloze.js +0 -112
- package/plugins/jspsych-external-html.js +0 -112
- package/plugins/jspsych-free-sort.js +0 -478
- package/plugins/jspsych-fullscreen.js +0 -106
- package/plugins/jspsych-html-button-response.js +0 -188
- package/plugins/jspsych-html-keyboard-response.js +0 -149
- package/plugins/jspsych-html-slider-response.js +0 -202
- package/plugins/jspsych-iat-html.js +0 -284
- package/plugins/jspsych-iat-image.js +0 -286
- package/plugins/jspsych-image-button-response.js +0 -327
- package/plugins/jspsych-image-keyboard-response.js +0 -263
- package/plugins/jspsych-image-slider-response.js +0 -369
- package/plugins/jspsych-instructions.js +0 -237
- package/plugins/jspsych-maxdiff.js +0 -173
- package/plugins/jspsych-preload.js +0 -345
- package/plugins/jspsych-rdk.js +0 -1373
- package/plugins/jspsych-reconstruction.js +0 -134
- package/plugins/jspsych-resize.js +0 -166
- package/plugins/jspsych-same-different-html.js +0 -168
- package/plugins/jspsych-same-different-image.js +0 -169
- package/plugins/jspsych-serial-reaction-time-mouse.js +0 -212
- package/plugins/jspsych-serial-reaction-time.js +0 -247
- package/plugins/jspsych-survey-html-form.js +0 -171
- package/plugins/jspsych-survey-likert.js +0 -195
- package/plugins/jspsych-survey-multi-choice.js +0 -208
- package/plugins/jspsych-survey-multi-select.js +0 -232
- package/plugins/jspsych-survey-text.js +0 -185
- package/plugins/jspsych-video-button-response.js +0 -335
- package/plugins/jspsych-video-keyboard-response.js +0 -279
- package/plugins/jspsych-video-slider-response.js +0 -351
- package/plugins/jspsych-virtual-chinrest.js +0 -471
- package/plugins/jspsych-visual-search-circle.js +0 -259
- package/plugins/jspsych-vsl-animate-occlusion.js +0 -196
- package/plugins/jspsych-vsl-grid-scene.js +0 -103
- package/plugins/jspsych-webgazer-calibrate.js +0 -161
- package/plugins/jspsych-webgazer-init-camera.js +0 -139
- package/plugins/jspsych-webgazer-validate.js +0 -314
- package/plugins/template/jspsych-plugin-template.js +0 -35
- package/tests/README.md +0 -7
- package/tests/jsPsych/case-sensitive-responses.test.js +0 -53
- package/tests/jsPsych/css-classes-parameter.test.js +0 -107
- package/tests/jsPsych/default-iti.test.js +0 -51
- package/tests/jsPsych/default-parameters.test.js +0 -58
- package/tests/jsPsych/endexperiment.test.js +0 -49
- package/tests/jsPsych/events.test.js +0 -606
- package/tests/jsPsych/functions-as-parameters.test.js +0 -210
- package/tests/jsPsych/init.test.js +0 -48
- package/tests/jsPsych/loads.test.js +0 -7
- package/tests/jsPsych/min-rt.test.js +0 -58
- package/tests/jsPsych/progressbar.test.js +0 -202
- package/tests/jsPsych/timeline-variables.test.js +0 -531
- package/tests/jsPsych/timelines.test.js +0 -569
- package/tests/jsPsych.data/data-csv-conversion.test.js +0 -85
- package/tests/jsPsych.data/data-json-conversion.test.js +0 -120
- package/tests/jsPsych.data/datacollection.test.js +0 -117
- package/tests/jsPsych.data/datacolumn.test.js +0 -50
- package/tests/jsPsych.data/datamodule.test.js +0 -152
- package/tests/jsPsych.data/dataparameter.test.js +0 -251
- package/tests/jsPsych.data/interactions.test.js +0 -109
- package/tests/jsPsych.data/trialparameters.test.js +0 -175
- package/tests/jsPsych.extensions/extensions.test.js +0 -207
- package/tests/jsPsych.extensions/test-extension.js +0 -42
- package/tests/jsPsych.pluginAPI/pluginapi.test.js +0 -365
- package/tests/jsPsych.pluginAPI/preloads.test.js +0 -43
- package/tests/jsPsych.randomization/randomziation.test.js +0 -27
- package/tests/jsPsych.utils/utils.test.js +0 -58
- package/tests/plugins/plugin-animation.test.js +0 -34
- package/tests/plugins/plugin-audio-button-response.test.js +0 -15
- package/tests/plugins/plugin-audio-keyboard-response.test.js +0 -15
- package/tests/plugins/plugin-audio-slider-response.test.js +0 -15
- package/tests/plugins/plugin-call-function.test.js +0 -49
- package/tests/plugins/plugin-categorize-animation.test.js +0 -263
- package/tests/plugins/plugin-categorize-html.test.js +0 -17
- package/tests/plugins/plugin-categorize-image.test.js +0 -17
- package/tests/plugins/plugin-cloze.test.js +0 -157
- package/tests/plugins/plugin-free-sort.test.js +0 -106
- package/tests/plugins/plugin-fullscreen.test.js +0 -41
- package/tests/plugins/plugin-html-button-response.test.js +0 -161
- package/tests/plugins/plugin-html-keyboard-response.test.js +0 -139
- package/tests/plugins/plugin-html-slider-response.test.js +0 -155
- package/tests/plugins/plugin-iat-html.test.js +0 -299
- package/tests/plugins/plugin-iat-image.test.js +0 -298
- package/tests/plugins/plugin-image-button-response.test.js +0 -174
- package/tests/plugins/plugin-image-keyboard-response.test.js +0 -147
- package/tests/plugins/plugin-image-slider-response.test.js +0 -174
- package/tests/plugins/plugin-instructions.test.js +0 -85
- package/tests/plugins/plugin-maxdiff.test.js +0 -39
- package/tests/plugins/plugin-preload.test.js +0 -916
- package/tests/plugins/plugin-rdk.test.js +0 -61
- package/tests/plugins/plugin-reconstruction.test.js +0 -16
- package/tests/plugins/plugin-resize.test.js +0 -16
- package/tests/plugins/plugin-same-different-html.test.js +0 -17
- package/tests/plugins/plugin-same-different-image.test.js +0 -17
- package/tests/plugins/plugin-serial-reaction-time-mouse.test.js +0 -42
- package/tests/plugins/plugin-serial-reaction-time.test.js +0 -109
- package/tests/plugins/plugin-survey-html-form.test.js +0 -44
- package/tests/plugins/plugin-survey-likert.test.js +0 -48
- package/tests/plugins/plugin-survey-multi-choice.test.js +0 -47
- package/tests/plugins/plugin-survey-multi-select.test.js +0 -71
- package/tests/plugins/plugin-survey-text.test.js +0 -115
- package/tests/plugins/plugin-video-button-response.test.js +0 -32
- package/tests/plugins/plugin-video-keyboard-response.test.js +0 -32
- package/tests/plugins/plugin-video-slider-response.test.js +0 -31
- package/tests/plugins/plugin-visual-search-circle.test.js +0 -16
- package/tests/plugins/plugin-vsl-animate-occlusion.test.js +0 -16
- package/tests/plugins/plugin-vsl-grid-scene.test.js +0 -16
- package/tests/testing-utils.js +0 -13
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const root = '../../';
|
|
2
|
-
const utils = require('../testing-utils.js');
|
|
3
|
-
|
|
4
|
-
jest.useFakeTimers();
|
|
5
|
-
|
|
6
|
-
describe('data conversion to json', function(){
|
|
7
|
-
|
|
8
|
-
beforeEach(function(){
|
|
9
|
-
require(root + 'jspsych.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('survey-text data response object is correctly converted', function(){
|
|
13
|
-
require(root + 'plugins/jspsych-survey-text.js');
|
|
14
|
-
|
|
15
|
-
var trial = {
|
|
16
|
-
type: 'survey-text',
|
|
17
|
-
questions: [
|
|
18
|
-
{prompt: 'Q1'},
|
|
19
|
-
{prompt: 'Q2'}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var timeline = [trial];
|
|
24
|
-
|
|
25
|
-
jsPsych.init({timeline});
|
|
26
|
-
|
|
27
|
-
document.querySelector('#input-0').value = 'Response 1';
|
|
28
|
-
document.querySelector('#input-1').value = 'Response 2';
|
|
29
|
-
|
|
30
|
-
utils.clickTarget(document.querySelector('#jspsych-survey-text-next'));
|
|
31
|
-
|
|
32
|
-
var json_data = jsPsych.data.get().ignore(['rt','internal_node_id', 'time_elapsed', 'trial_type']).json();
|
|
33
|
-
expect(json_data).toBe(JSON.stringify([{response: {Q0: "Response 1", Q1: "Response 2"}, trial_index: 0}]));
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('same-different-html stimulus array is correctly converted', function(){
|
|
37
|
-
require(root + 'plugins/jspsych-same-different-html.js');
|
|
38
|
-
|
|
39
|
-
var trial = {
|
|
40
|
-
type: 'same-different-html',
|
|
41
|
-
stimuli: ['<p>Climbing</p>', '<p>Walking</p>'],
|
|
42
|
-
answer: 'different',
|
|
43
|
-
gap_duration: 0,
|
|
44
|
-
first_stim_duration: null
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var timeline = [trial];
|
|
48
|
-
|
|
49
|
-
jsPsych.init({timeline: timeline});
|
|
50
|
-
|
|
51
|
-
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<p>Climbing</p>');
|
|
52
|
-
utils.pressKey('q');
|
|
53
|
-
jest.runAllTimers();
|
|
54
|
-
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<p>Walking</p>');
|
|
55
|
-
utils.pressKey('q');
|
|
56
|
-
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
|
|
57
|
-
|
|
58
|
-
var json_data = jsPsych.data.get().ignore(['rt','internal_node_id','time_elapsed','trial_type','rt_stim1','response_stim1']).json();
|
|
59
|
-
expect(json_data).toBe(JSON.stringify([{answer: 'different', correct: false, stimulus: ['<p>Climbing</p>','<p>Walking</p>'], response: 'q', trial_index: 0}]));
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test('survey-multi-select response array is correctly converted', function(){
|
|
63
|
-
require(root + 'plugins/jspsych-survey-multi-select.js');
|
|
64
|
-
|
|
65
|
-
var trial = {
|
|
66
|
-
type: 'survey-multi-select',
|
|
67
|
-
questions: [
|
|
68
|
-
{prompt: "foo", options: ["fuzz", "bizz", "bar"], name: 'q'}
|
|
69
|
-
]
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var timeline = [trial];
|
|
73
|
-
|
|
74
|
-
jsPsych.init({timeline: timeline});
|
|
75
|
-
|
|
76
|
-
expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo');
|
|
77
|
-
utils.clickTarget(document.querySelector('#jspsych-survey-multi-select-response-0-0'));
|
|
78
|
-
utils.clickTarget(document.querySelector('#jspsych-survey-multi-select-response-0-1'));
|
|
79
|
-
utils.clickTarget(document.querySelector('#jspsych-survey-multi-select-next'));
|
|
80
|
-
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
|
|
81
|
-
|
|
82
|
-
var json_data = jsPsych.data.get().ignore(['rt','internal_node_id','time_elapsed','trial_type','question_order']).json();
|
|
83
|
-
var data_js = [
|
|
84
|
-
{
|
|
85
|
-
response: {
|
|
86
|
-
q: ["fuzz","bizz"],
|
|
87
|
-
},
|
|
88
|
-
trial_index: 0
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
expect(json_data).toBe(JSON.stringify(data_js));
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
test('instructions view_history is correctly converted - issue #670', function(){
|
|
95
|
-
require(root + 'plugins/jspsych-instructions.js');
|
|
96
|
-
|
|
97
|
-
var trial = {
|
|
98
|
-
type: 'instructions',
|
|
99
|
-
pages: ['page 1','page 2'],
|
|
100
|
-
key_forward: 'a',
|
|
101
|
-
allow_keys: true
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
jsPsych.init({timeline: [trial]});
|
|
105
|
-
|
|
106
|
-
expect(jsPsych.getDisplayElement().innerHTML).toMatch('page 1');
|
|
107
|
-
utils.pressKey('a');
|
|
108
|
-
expect(jsPsych.getDisplayElement().innerHTML).toMatch('page 2');
|
|
109
|
-
utils.pressKey('a');
|
|
110
|
-
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
|
|
111
|
-
|
|
112
|
-
var json_data = jsPsych.data.get().ignore(['rt','internal_node_id','time_elapsed']).json();
|
|
113
|
-
var js_data = JSON.parse(json_data);
|
|
114
|
-
expect(Array.isArray(js_data[0].view_history)).toBe(true);
|
|
115
|
-
expect(js_data[0].view_history.length).toBe(2);
|
|
116
|
-
expect(js_data[0].view_history[0].page_index).toBe(0);
|
|
117
|
-
expect(js_data[0].view_history[1].page_index).toBe(1);
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
const root = '../../';
|
|
2
|
-
|
|
3
|
-
require(root + 'jspsych.js');
|
|
4
|
-
|
|
5
|
-
var data = [
|
|
6
|
-
{rt: 100, filter: true},
|
|
7
|
-
{rt: 200, filter: false},
|
|
8
|
-
{rt: 300, filter: true},
|
|
9
|
-
{rt: 400, filter: false},
|
|
10
|
-
{rt: 500, filter: false}
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
jsPsych.data._customInsert(data);
|
|
14
|
-
|
|
15
|
-
describe('DataCollection', function(){
|
|
16
|
-
test('#filter', function(){
|
|
17
|
-
expect(jsPsych.data.get().filter({filter: true}).count()).toBe(2);
|
|
18
|
-
});
|
|
19
|
-
test('#filter OR', function(){
|
|
20
|
-
expect(jsPsych.data.get().filter([{filter: true}, {rt: 300}]).count()).toBe(2);
|
|
21
|
-
expect(jsPsych.data.get().filter([{filter: true}, {rt: 200}]).count()).toBe(3);
|
|
22
|
-
})
|
|
23
|
-
test('#filterCustom', function(){
|
|
24
|
-
expect(jsPsych.data.get().filterCustom(function(x){ return x.rt > 200 && x.filter == false}).count()).toBe(2);
|
|
25
|
-
});
|
|
26
|
-
test('#ignore', function(){
|
|
27
|
-
expect(jsPsych.data.get().ignore('rt').select('rt').count()).toBe(0);
|
|
28
|
-
});
|
|
29
|
-
test('#select', function(){
|
|
30
|
-
expect(JSON.stringify(jsPsych.data.get().select('rt').values)).toBe(JSON.stringify([100,200,300,400,500]));
|
|
31
|
-
});
|
|
32
|
-
test('#addToAll', function(){
|
|
33
|
-
expect(jsPsych.data.get().readOnly().addToAll({added: 5}).select('added').count()).toBe(5);
|
|
34
|
-
});
|
|
35
|
-
test('#addToLast', function(){
|
|
36
|
-
jsPsych.data.get().addToLast({lastonly: true});
|
|
37
|
-
expect(jsPsych.data.get().values()[4].lastonly).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
test('#readOnly', function(){
|
|
40
|
-
var d = jsPsych.data.get().readOnly().values();
|
|
41
|
-
d[0].rt = 0;
|
|
42
|
-
expect(jsPsych.data.get().values()[0].rt).toBe(100);
|
|
43
|
-
});
|
|
44
|
-
test('not #readOnly', function(){
|
|
45
|
-
var d = jsPsych.data.get().values();
|
|
46
|
-
d[0].rt = 0;
|
|
47
|
-
expect(jsPsych.data.get().values()[0].rt).toBe(0);
|
|
48
|
-
});
|
|
49
|
-
test('#count', function(){
|
|
50
|
-
expect(jsPsych.data.get().count()).toBe(5);
|
|
51
|
-
});
|
|
52
|
-
test('#push', function(){
|
|
53
|
-
jsPsych.data.get().push({rt: 600, filter: true});
|
|
54
|
-
expect(jsPsych.data.get().count()).toBe(6);
|
|
55
|
-
data = [
|
|
56
|
-
{rt: 100, filter: true},
|
|
57
|
-
{rt: 200, filter: false},
|
|
58
|
-
{rt: 300, filter: true},
|
|
59
|
-
{rt: 400, filter: false},
|
|
60
|
-
{rt: 500, filter: false}
|
|
61
|
-
];
|
|
62
|
-
jsPsych.data._customInsert(data);
|
|
63
|
-
});
|
|
64
|
-
test('#values', function(){
|
|
65
|
-
expect(JSON.stringify(jsPsych.data.get().values())).toBe(JSON.stringify(data));
|
|
66
|
-
expect(jsPsych.data.get().values()).toBe(data);
|
|
67
|
-
});
|
|
68
|
-
test('#first', function(){
|
|
69
|
-
expect(jsPsych.data.get().first(3).count()).toBe(3);
|
|
70
|
-
expect(jsPsych.data.get().first(2).values()[1].rt).toBe(200);
|
|
71
|
-
expect(jsPsych.data.get().first().count()).toBe(1);
|
|
72
|
-
expect(() => {
|
|
73
|
-
jsPsych.data.get().first(-1)
|
|
74
|
-
}).toThrow();
|
|
75
|
-
expect(() => {
|
|
76
|
-
jsPsych.data.get().first(0)
|
|
77
|
-
}).toThrow();
|
|
78
|
-
expect(jsPsych.data.get().filter({foo: "bar"}).first(1).count()).toBe(0);
|
|
79
|
-
var n = jsPsych.data.get().count();
|
|
80
|
-
var too_many = n+1;
|
|
81
|
-
expect(jsPsych.data.get().first(too_many).count()).toBe(n);
|
|
82
|
-
});
|
|
83
|
-
test('#last', function(){
|
|
84
|
-
expect(jsPsych.data.get().last(2).count(2)).toBe(2);
|
|
85
|
-
expect(jsPsych.data.get().last(2).values()[0].rt).toBe(400);
|
|
86
|
-
expect(jsPsych.data.get().last().count()).toBe(1);
|
|
87
|
-
expect(() => {
|
|
88
|
-
jsPsych.data.get().last(-1)
|
|
89
|
-
}).toThrow();
|
|
90
|
-
expect(() => {
|
|
91
|
-
jsPsych.data.get().last(0)
|
|
92
|
-
}).toThrow();
|
|
93
|
-
expect(jsPsych.data.get().filter({foo: "bar"}).last(1).count()).toBe(0);
|
|
94
|
-
var n = jsPsych.data.get().count();
|
|
95
|
-
var too_many = n+1;
|
|
96
|
-
expect(jsPsych.data.get().last(too_many).count()).toBe(n);
|
|
97
|
-
});
|
|
98
|
-
test('#join', function(){
|
|
99
|
-
var dc1 = jsPsych.data.get().filter({filter: true});
|
|
100
|
-
var dc2 = jsPsych.data.get().filter({rt: 500});
|
|
101
|
-
var data = dc1.join(dc2);
|
|
102
|
-
expect(data.count()).toBe(3);
|
|
103
|
-
expect(data.values()[2].rt).toBe(500);
|
|
104
|
-
});
|
|
105
|
-
test('#unqiueNames', function(){
|
|
106
|
-
var data = [
|
|
107
|
-
{rt: 100, filter: true},
|
|
108
|
-
{rt: 200, filter: false},
|
|
109
|
-
{rt: 300, filter: true, v1: false},
|
|
110
|
-
{rt: 400, filter: false, v2: true},
|
|
111
|
-
{rt: 500, filter: false, v1: false}
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
jsPsych.data._customInsert(data);
|
|
115
|
-
expect(jsPsych.data.get().uniqueNames().length).toBe(4);
|
|
116
|
-
})
|
|
117
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const root = '../../';
|
|
2
|
-
|
|
3
|
-
require(root + 'jspsych.js');
|
|
4
|
-
|
|
5
|
-
var data = [
|
|
6
|
-
{rt: 100, filter: true},
|
|
7
|
-
{rt: 200, filter: false},
|
|
8
|
-
{rt: 300, filter: true},
|
|
9
|
-
{rt: 400, filter: false},
|
|
10
|
-
{rt: 500, filter: false}
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
jsPsych.data._customInsert(data);
|
|
14
|
-
|
|
15
|
-
describe('DataColumn', function(){
|
|
16
|
-
test('#sum', function(){
|
|
17
|
-
expect(jsPsych.data.get().select('rt').sum()).toBe(1500);
|
|
18
|
-
});
|
|
19
|
-
test('#mean', function(){
|
|
20
|
-
expect(jsPsych.data.get().select('rt').mean()).toBe(300);
|
|
21
|
-
});
|
|
22
|
-
test('#count', function(){
|
|
23
|
-
expect(jsPsych.data.get().select('rt').count()).toBe(5);
|
|
24
|
-
});
|
|
25
|
-
test('#min', function(){
|
|
26
|
-
expect(jsPsych.data.get().select('rt').min()).toBe(100);
|
|
27
|
-
});
|
|
28
|
-
test('#max', function(){
|
|
29
|
-
expect(jsPsych.data.get().select('rt').max()).toBe(500);
|
|
30
|
-
});
|
|
31
|
-
test('#variance', function(){
|
|
32
|
-
expect(jsPsych.data.get().select('rt').variance()).toBe((Math.pow(200,2)+Math.pow(100,2)+Math.pow(100,2)+Math.pow(200,2))/(5-1));
|
|
33
|
-
});
|
|
34
|
-
test('#sd', function(){
|
|
35
|
-
expect(jsPsych.data.get().select('rt').sd()).toBe(Math.sqrt((Math.pow(200,2)+Math.pow(100,2)+Math.pow(100,2)+Math.pow(200,2))/(5-1)));
|
|
36
|
-
});
|
|
37
|
-
test('#median', function(){
|
|
38
|
-
expect(jsPsych.data.get().select('rt').median()).toBe(300);
|
|
39
|
-
});
|
|
40
|
-
test('#subset', function(){
|
|
41
|
-
expect(jsPsych.data.get().select('rt').subset(function(x){ return x > 300; }).count()).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
test('#frequencies', function(){
|
|
44
|
-
expect(jsPsych.data.get().select('filter').frequencies()).toEqual({true:2, false: 3})
|
|
45
|
-
});
|
|
46
|
-
test('#all', function(){
|
|
47
|
-
expect(jsPsych.data.get().select('rt').all(function(x){ return x < 600})).toBe(true);
|
|
48
|
-
expect(jsPsych.data.get().select('filter').all(function(x){ return x; })).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
const root = '../../';
|
|
2
|
-
const utils = require('../testing-utils.js');
|
|
3
|
-
|
|
4
|
-
require(root + 'jspsych.js');
|
|
5
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
6
|
-
|
|
7
|
-
describe('Basic data recording', function(){
|
|
8
|
-
test('should be able to get rt after running experiment', function(){
|
|
9
|
-
var timeline = [
|
|
10
|
-
{type: 'html-keyboard-response', stimulus:'hello'}
|
|
11
|
-
];
|
|
12
|
-
jsPsych.init({timeline:timeline});
|
|
13
|
-
// click through first trial
|
|
14
|
-
utils.pressKey('a');
|
|
15
|
-
// check if data contains rt
|
|
16
|
-
expect(jsPsych.data.get().select('rt').count()).toBe(1);
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe('#addProperties', function(){
|
|
21
|
-
|
|
22
|
-
test('should add data to all trials if called before experiment starts', function(){
|
|
23
|
-
var timeline = [
|
|
24
|
-
{type: 'html-keyboard-response', stimulus:'hello'}
|
|
25
|
-
];
|
|
26
|
-
jsPsych.data.addProperties({'testprop': 1});
|
|
27
|
-
jsPsych.init({timeline:timeline});
|
|
28
|
-
// click through first trial
|
|
29
|
-
utils.pressKey('a');
|
|
30
|
-
// check if data contains testprop
|
|
31
|
-
expect(jsPsych.data.get().select('testprop').count()).toBe(1);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('should add data to all trials retroactively', function(){
|
|
35
|
-
jsPsych.data._fullreset();
|
|
36
|
-
var timeline = [
|
|
37
|
-
{type: 'html-keyboard-response', stimulus:'hello'}
|
|
38
|
-
];
|
|
39
|
-
jsPsych.init({timeline:timeline});
|
|
40
|
-
// click through first trial
|
|
41
|
-
utils.pressKey('a');
|
|
42
|
-
// check if data contains testprop
|
|
43
|
-
expect(jsPsych.data.get().select('testprop').count()).toBe(0);
|
|
44
|
-
jsPsych.data.addProperties({'testprop': 1});
|
|
45
|
-
expect(jsPsych.data.get().select('testprop').count()).toBe(1);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('#addDataToLastTrial', function(){
|
|
51
|
-
test('should add any data properties to the last trial', function(){
|
|
52
|
-
jsPsych.data._fullreset();
|
|
53
|
-
var timeline = [
|
|
54
|
-
{
|
|
55
|
-
type: 'html-keyboard-response',
|
|
56
|
-
stimulus: 'hello',
|
|
57
|
-
on_finish: function(){
|
|
58
|
-
jsPsych.data.addDataToLastTrial({testA: 1, testB: 2});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
];
|
|
62
|
-
jsPsych.init({timeline:timeline});
|
|
63
|
-
// click through first trial
|
|
64
|
-
utils.pressKey('a');
|
|
65
|
-
// check data structure
|
|
66
|
-
expect(jsPsych.data.get().select('testA').values[0]).toBe(1);
|
|
67
|
-
expect(jsPsych.data.get().select('testB').values[0]).toBe(2);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('#getLastTrialData', function(){
|
|
72
|
-
test('should return a new DataCollection with only the last trial\'s data', function(){
|
|
73
|
-
jsPsych.data._fullreset();
|
|
74
|
-
var timeline = [
|
|
75
|
-
{type: 'html-keyboard-response', stimulus:'hello'},
|
|
76
|
-
{type: 'html-keyboard-response', stimulus:'world'}
|
|
77
|
-
];
|
|
78
|
-
jsPsych.init({timeline:timeline});
|
|
79
|
-
// click through first trial
|
|
80
|
-
utils.pressKey('a');
|
|
81
|
-
// click through second trial
|
|
82
|
-
utils.pressKey('a');
|
|
83
|
-
// check data structure
|
|
84
|
-
expect(jsPsych.data.getLastTrialData().select('trial_index').values[0]).toBe(1);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('#getLastTimelineData', function(){
|
|
89
|
-
test('should return a new DataCollection with only the last timeline\'s data', function(){
|
|
90
|
-
jsPsych.data._fullreset();
|
|
91
|
-
var timeline = [
|
|
92
|
-
{
|
|
93
|
-
timeline:
|
|
94
|
-
[
|
|
95
|
-
{type: 'html-keyboard-response', stimulus:'hello'},
|
|
96
|
-
{type: 'html-keyboard-response', stimulus:'world'},
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
timeline:
|
|
101
|
-
[
|
|
102
|
-
{type: 'html-keyboard-response', stimulus:'second'},
|
|
103
|
-
{type: 'html-keyboard-response', stimulus:'time'},
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
];
|
|
107
|
-
jsPsych.init({timeline:timeline});
|
|
108
|
-
// click through all four trials
|
|
109
|
-
for(var i=0; i<4; i++){
|
|
110
|
-
utils.pressKey('a');
|
|
111
|
-
}
|
|
112
|
-
// check data structure
|
|
113
|
-
expect(jsPsych.data.getLastTimelineData().count()).toBe(2);
|
|
114
|
-
expect(jsPsych.data.getLastTimelineData().select('trial_index').values[0]).toBe(2);
|
|
115
|
-
expect(jsPsych.data.getLastTimelineData().select('trial_index').values[1]).toBe(3);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('#displayData', function(){
|
|
120
|
-
test('should display in json format', function(){
|
|
121
|
-
var timeline = [
|
|
122
|
-
{type: 'html-keyboard-response', stimulus:'hello'}
|
|
123
|
-
];
|
|
124
|
-
jsPsych.init({timeline:timeline});
|
|
125
|
-
// click through first trial
|
|
126
|
-
utils.pressKey('a');
|
|
127
|
-
// overwrite data with custom data
|
|
128
|
-
var data = [{col1: 1, col2: 2}, {col1: 3, col2: 4}]
|
|
129
|
-
jsPsych.data._customInsert(data);
|
|
130
|
-
// display data in json format
|
|
131
|
-
jsPsych.data.displayData('json');
|
|
132
|
-
// get display element HTML
|
|
133
|
-
var html = jsPsych.getDisplayElement().innerHTML;
|
|
134
|
-
expect(html).toBe('<pre id="jspsych-data-display">'+JSON.stringify(data, null, '\t')+'</pre>');
|
|
135
|
-
});
|
|
136
|
-
test('should display in csv format', function(){
|
|
137
|
-
var timeline = [
|
|
138
|
-
{type: 'html-keyboard-response', stimulus:'hello'}
|
|
139
|
-
];
|
|
140
|
-
jsPsych.init({timeline:timeline});
|
|
141
|
-
// click through first trial
|
|
142
|
-
utils.pressKey('a');
|
|
143
|
-
// overwrite data with custom data
|
|
144
|
-
var data = [{col1: 1, col2: 2}, {col1: 3, col2: 4}]
|
|
145
|
-
jsPsych.data._customInsert(data);
|
|
146
|
-
// display data in json format
|
|
147
|
-
jsPsych.data.displayData('csv');
|
|
148
|
-
// get display element HTML
|
|
149
|
-
var html = jsPsych.getDisplayElement().innerHTML;
|
|
150
|
-
expect(html).toBe("<pre id=\"jspsych-data-display\">\"col1\",\"col2\"\r\n\"1\",\"2\"\r\n\"3\",\"4\"\r\n</pre>");
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
const root = '../../';
|
|
2
|
-
const utils = require('../testing-utils.js');
|
|
3
|
-
|
|
4
|
-
describe('The data parameter', function(){
|
|
5
|
-
test('should record data to a trial', function(){
|
|
6
|
-
|
|
7
|
-
require(root + 'jspsych.js');
|
|
8
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
9
|
-
|
|
10
|
-
return (new Promise(function(resolve, reject){
|
|
11
|
-
|
|
12
|
-
var key_data = null;
|
|
13
|
-
|
|
14
|
-
var trial = {
|
|
15
|
-
type: 'html-keyboard-response',
|
|
16
|
-
stimulus: 'hello',
|
|
17
|
-
data: {added: true},
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
jsPsych.init({
|
|
21
|
-
timeline: [trial],
|
|
22
|
-
on_finish: function() {
|
|
23
|
-
var d = jsPsych.data.get().values()[0].added;
|
|
24
|
-
resolve(d);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
utils.pressKey('a');
|
|
29
|
-
|
|
30
|
-
//resolve();
|
|
31
|
-
})).then(function(data) { expect(data).toBe(true) });
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('should record data to all nested trials', function(){
|
|
35
|
-
|
|
36
|
-
require(root + 'jspsych.js');
|
|
37
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
38
|
-
|
|
39
|
-
return (new Promise(function(resolve, reject){
|
|
40
|
-
|
|
41
|
-
var key_data = null;
|
|
42
|
-
|
|
43
|
-
var trial = {
|
|
44
|
-
type: 'html-keyboard-response',
|
|
45
|
-
timeline: [
|
|
46
|
-
{stimulus: 'a'},
|
|
47
|
-
{stimulus: 'b'}
|
|
48
|
-
],
|
|
49
|
-
data: {added: true},
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
jsPsych.init({
|
|
53
|
-
timeline: [trial],
|
|
54
|
-
on_finish: function() {
|
|
55
|
-
var d = jsPsych.data.get().filter({added: true}).count();
|
|
56
|
-
resolve(d);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
utils.pressKey('a');
|
|
61
|
-
|
|
62
|
-
utils.pressKey('a');
|
|
63
|
-
|
|
64
|
-
//resolve();
|
|
65
|
-
})).then(function(data) { expect(data).toBe(2) });
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('should record data to all nested trials with timeline variables', function(){
|
|
69
|
-
|
|
70
|
-
require(root + 'jspsych.js');
|
|
71
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
72
|
-
|
|
73
|
-
return (new Promise(function(resolve, reject){
|
|
74
|
-
|
|
75
|
-
var key_data = null;
|
|
76
|
-
|
|
77
|
-
var vars = [
|
|
78
|
-
{stimulus: 'a'},
|
|
79
|
-
{stimulus: 'b'}
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
var trial = {
|
|
83
|
-
timeline: [
|
|
84
|
-
{type: 'html-keyboard-response',
|
|
85
|
-
stimulus: jsPsych.timelineVariable('stimulus')}
|
|
86
|
-
],
|
|
87
|
-
timeline_variables: vars,
|
|
88
|
-
data: {added: true},
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
jsPsych.init({
|
|
92
|
-
timeline: [trial],
|
|
93
|
-
on_finish: function() {
|
|
94
|
-
var d = jsPsych.data.get().filter({added: true}).count();
|
|
95
|
-
resolve(d);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
utils.pressKey('a');
|
|
100
|
-
|
|
101
|
-
utils.pressKey('a');
|
|
102
|
-
|
|
103
|
-
//resolve();
|
|
104
|
-
})).then(function(data) { expect(data).toBe(2) });
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('should work as timeline variable at root level', function(){
|
|
108
|
-
require(root + 'jspsych.js');
|
|
109
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
110
|
-
|
|
111
|
-
var trial = {
|
|
112
|
-
timeline: [
|
|
113
|
-
{type: 'html-keyboard-response', stimulus: 'foo', data: jsPsych.timelineVariable('d')}
|
|
114
|
-
],
|
|
115
|
-
timeline_variables: [
|
|
116
|
-
{d: {added: true}},
|
|
117
|
-
{d: {added: false}}
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
jsPsych.init({
|
|
122
|
-
timeline: [trial]
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
utils.pressKey('a'); // trial 1
|
|
126
|
-
utils.pressKey('a'); // trial 2
|
|
127
|
-
|
|
128
|
-
expect(jsPsych.data.get().filter({added: true}).count()).toBe(1);
|
|
129
|
-
expect(jsPsych.data.get().filter({added: false}).count()).toBe(1);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
test('should work as timeline variable at nested level', function(){
|
|
133
|
-
require(root + 'jspsych.js');
|
|
134
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
135
|
-
|
|
136
|
-
var trial = {
|
|
137
|
-
timeline: [
|
|
138
|
-
{type: 'html-keyboard-response', stimulus: 'foo', data: {added: jsPsych.timelineVariable('added')}}
|
|
139
|
-
],
|
|
140
|
-
timeline_variables: [
|
|
141
|
-
{added: true},
|
|
142
|
-
{added: false}
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
jsPsych.init({
|
|
147
|
-
timeline: [trial]
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
utils.pressKey('a'); // trial 1
|
|
151
|
-
utils.pressKey('a'); // trial 2
|
|
152
|
-
|
|
153
|
-
expect(jsPsych.data.get().filter({added: true}).count()).toBe(1);
|
|
154
|
-
expect(jsPsych.data.get().filter({added: false}).count()).toBe(1);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test('timeline variable should be available in trial on_finish', function(){
|
|
158
|
-
require(root + 'jspsych.js');
|
|
159
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
160
|
-
|
|
161
|
-
var trial = {
|
|
162
|
-
timeline: [
|
|
163
|
-
{
|
|
164
|
-
type: 'html-keyboard-response',
|
|
165
|
-
stimulus: 'foo',
|
|
166
|
-
data: {added: jsPsych.timelineVariable('added')},
|
|
167
|
-
on_finish: function(data){
|
|
168
|
-
data.added_copy = data.added;
|
|
169
|
-
}}
|
|
170
|
-
],
|
|
171
|
-
timeline_variables: [
|
|
172
|
-
{added: true},
|
|
173
|
-
{added: false}
|
|
174
|
-
]
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
jsPsych.init({
|
|
178
|
-
timeline: [trial]
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
utils.pressKey('a'); // trial 1
|
|
182
|
-
utils.pressKey('a'); // trial 2
|
|
183
|
-
|
|
184
|
-
expect(jsPsych.data.get().filter({added_copy: true}).count()).toBe(1);
|
|
185
|
-
expect(jsPsych.data.get().filter({added_copy: false}).count()).toBe(1);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test('should record data to all nested trials with timeline variables even when nested trials have own data', function(){
|
|
189
|
-
|
|
190
|
-
require(root + 'jspsych.js');
|
|
191
|
-
require(root + 'plugins/jspsych-html-keyboard-response.js');
|
|
192
|
-
|
|
193
|
-
return (new Promise(function(resolve, reject){
|
|
194
|
-
|
|
195
|
-
var key_data = null;
|
|
196
|
-
|
|
197
|
-
var vars = [
|
|
198
|
-
{stimulus: 'a'},
|
|
199
|
-
{stimulus: 'b'}
|
|
200
|
-
];
|
|
201
|
-
|
|
202
|
-
var trial = {
|
|
203
|
-
timeline: [
|
|
204
|
-
{
|
|
205
|
-
type: 'html-keyboard-response',
|
|
206
|
-
stimulus: jsPsych.timelineVariable('stimulus'),
|
|
207
|
-
data: {foo: 1}
|
|
208
|
-
}
|
|
209
|
-
],
|
|
210
|
-
timeline_variables: vars,
|
|
211
|
-
data: {added: true},
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
jsPsych.init({
|
|
215
|
-
timeline: [trial],
|
|
216
|
-
on_finish: function() {
|
|
217
|
-
var d = jsPsych.data.get().filter({added: true, foo: 1}).count();
|
|
218
|
-
resolve(d);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
utils.pressKey('a');
|
|
223
|
-
|
|
224
|
-
utils.pressKey('a');
|
|
225
|
-
|
|
226
|
-
//resolve();
|
|
227
|
-
})).then(function(data) { expect(data).toBe(2) });
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test('should accept a function as a parameter', function(done){
|
|
231
|
-
var trial = {
|
|
232
|
-
type: 'html-keyboard-response',
|
|
233
|
-
stimulus: 'foo',
|
|
234
|
-
data: {
|
|
235
|
-
a: function(){ return 1; }
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
var timeline = [trial];
|
|
240
|
-
|
|
241
|
-
jsPsych.init({
|
|
242
|
-
timeline: timeline,
|
|
243
|
-
on_finish: function(){
|
|
244
|
-
expect(jsPsych.data.get().values()[0].a).toBe(1);
|
|
245
|
-
done();
|
|
246
|
-
}
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
utils.pressKey('a');
|
|
250
|
-
})
|
|
251
|
-
});
|