merge in the video parameter name changes from master

This commit is contained in:
Becky Gilbert 2020-12-03 15:43:15 -08:00
commit a433d81c90
9 changed files with 76 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -5,16 +5,17 @@
**Supported**
jsPsych supports recent versions of the four most commonly-used web browsers:
* Chrome
* Firefox
* Safari
* Edge
* Chrome
* Firefox
* Safari
* Edge
This means that jsPsych _should_ work on these browsers. If something doesn't work as you expect on one of the browsers above, it might be a bug that should be fixed. You can search for and report bugs on the [jsPsych GitHub Issues page](https://github.com/jspsych/jsPsych/issues). We're very grateful for anyone who takes the time to report bugs - it helps improve the library for everyone!
**Unsupported**
There are many other web browsers that are available, but that are not commonly used. The most well-known of these are Internet Explorer and Opera. jsPsych is not tested on these and other browsers not listed in the Supported section above. jsPsych experiments _might_ work in these browsers, but they _might not_. If you want to give participants the option to use unsupported browsers, then we recommend carefully testing your experiment to make sure that everything works as expected. Otherwise, we suggest asking your participants to only use a supported browser, or incorporating browser, device, and/or feature checks at the start of your experiment. jsPsych offers built-in methods for [exclusion based on minimum browser size and WebAudio API compatibility](overview/exclude-browser.md). You can incorporate other browser/device/feature checks into your experiment by adding custom JavaScript code.
There are many other web browsers that are available, but that are not commonly used. The most well-known of these are Internet Explorer and Opera. jsPsych is not tested on these and other browsers not listed in the Supported section above. jsPsych experiments _might_ work in these browsers, but they _might not_. If you want to give participants the option to use unsupported browsers, then we recommend carefully testing your experiment to make sure that everything works as expected. Otherwise, we suggest asking your participants to only use a supported browser, or incorporating browser, device, and/or feature checks at the start of your experiment. jsPsych offers built-in methods for [exclusion based on minimum browser size and WebAudio API compatibility](/overview/exclude-browser.md). You can incorporate other browser/device/feature checks into your experiment by adding custom JavaScript code.
## Mobile Devices

View File

@ -1,6 +1,6 @@
# jspsych-maxdiff plugin
The maxdiff plugin displays a table with rows of alternatives to be endorsed, typically as 'most' or 'least' on a particular criteria (e.g. importance, preference, similarity). The participant responds by selecting one radio button corresponding to an alternative in both the left and right response columns. The same alternative cannot be endorsed on both the left and right response columns (e.g. 'most' and 'least') simultaneously.
The maxdiff plugin displays a table with rows of alternatives to be selected for two mutually-exclusive categories, typically as 'most' or 'least' on a particular criteria (e.g. importance, preference, similarity). The participant responds by selecting one radio button corresponding to an alternative in both the left and right response columns. The same alternative cannot be endorsed on both the left and right response columns (e.g. 'most' and 'least') simultaneously.
## Parameters

View File

@ -66,42 +66,46 @@ This table is a description of all plugins that are distributed with jsPsych. Cl
Plugin | Description
------ | -----------
[jspsych‑animation](jspsych-animation) | Shows a sequence of images at a specified frame rate. Records key presses (including timing information) made by the subject while they are viewing the animation.
[jspsych‑audio‑button‑response](jspsych-audio-button-response) | Play an audio file and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑audio‑keyboard‑response](jspsych-audio-keyboard-response) | Play an audio file and allow the subject to respond by pressing a key.
[jspsych‑audio‑slider‑response](jspsych-audio-slider-response) | Play an audio file and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑call‑function](jspsych-call-function) | Executes an arbitrary function call. Doesn't display anything to the subject, and the subject is usually unaware that this plugin has even executed. It's useful for performing tasks at specified times in the experiment, such as saving data.
[jspsych‑categorize‑animation](jspsych-categorize-animation) | The subject responds to an animation and can be given feedback about their response.
[jspsych‑categorize‑html](jspsych-categorize-html) | The subject responds to an HTML-formatted stimulus using the keyboard and can be given feedback about the correctness of their response.
[jspsych‑categorize‑image](jspsych-categorize-image) | The subject responds to an image using the keyboard and can be given feedback about the correctness of their response.
[jspsych‑cloze](jspsych-cloze) | Plugin for displaying a cloze test and checking participants answers against a correct solution.
[jspsych‑external‑html](jspsych-external-html) | Displays an external HTML page (such as a consent form) and lets the subject respond by clicking a button or pressing a key. Plugin can validate their response, which is useful for making sure that a subject has granted consent before starting the experiment.
[jspsych‑free‑sort](jspsych-free-sort) | Displays a set of images on the screen in random locations. Subjects can click and drag the images to move them around the screen. Records all the moves made by the subject, so the sequence of moves can be recovered from the data.
[jspsych‑fullscreen](jspsych-fullscreen) | Toggles the experiment in and out of fullscreen mode.
[jspsych‑html‑button‑response](jspsych-html-button-response) | Display an HTML-formatted stimulus and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑html‑keyboard‑response](jspsych-html-keyboard-response) | Display an HTML-formatted stimulus and allow the subject to respond by pressing a key.
[jspsych‑html‑slider‑response](jspsych-html-slider-response) | Display an HTML-formatted stimulus and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑iat‑html](jspsych-iat-html) | The implicit association task, using HTML-formatted stimuli.
[jspsych‑iat‑image](jspsych-iat-image) | The implicit association task, using images as stimuli.
[jspsych‑image‑button‑response](jspsych-image-button-response) | Display an image and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑image‑keyboard‑response](jspsych-image-keyboard-response) | Display an image and allow the subject to respond by pressing a key.
[jspsych‑image‑slider‑response](jspsych-image-slider-response) | Display an image and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑instructions](jspsych-instructions) | For displaying instructions to the subject. Allows the subject to navigate between pages of instructions using keys or buttons.
[jspsych‑rdk](jspsych-rdk) | This plugin displays a Random Dot Kinematogram (RDK) and allows the subject to report the primary direction of motion by pressing a key on the keyboard.
[jspsych‑reconstruction](jspsych-reconstruction) | The subject interacts with a stimulus by modifying a parameter of the stimulus and observing the change in the stimulus in real-time.
[jspsych‑resize](jspsych-resize) | Calibrate the display so that materials display with a known physical size.
[jspsych‑same‑different‑html](jspsych-same-different-html) | A same-different judgment task. An HTML-formatted stimulus is shown, followed by a brief gap, and then another stimulus is shown. The subject indicates whether the stimuli are the same or different.
[jspsych‑same‑different‑image](jspsych-same-different-image) | A same-different judgment task. An image is shown, followed by a brief gap, and then another stimulus is shown. The subject indicates whether the stimuli are the same or different.
[jspsych‑serial‑reaction‑time](jspsych-serial-reaction-time) | A set of boxes are displayed on the screen and one of them changes color. The subject presses a key that corresponds to the different color box as fast as possible.
[jspsych‑serial‑reaction‑time‑mouse](jspsych-serial-reaction-time-mouse) | A set of boxes are displayed on the screen and one of them changes color. The subjects clicks the box that changed color as fast as possible.
[jspsych‑survey‑html‑form](jspsych-survey-html-form) | Renders a custom HTML form. Allows for mixing multiple kinds of form input.
[jspsych‑survey‑likert](jspsych-survey-likert) | Displays likert-style questions.
[jspsych‑survey‑multi‑choice](jspsych-survey-multi-choice) | Displays multiple choice questions with one answer allowed per question.
[jspsych‑survey‑multi‑select](jspsych-survey-multi-select) | Displays multiple choice questions with multiple answes allowed per question.
[jspsych‑survey‑text](jspsych-survey-text) | Shows a prompt with a text box. The subject writes a response and then submits by clicking a button.
[jspsych‑video‑button‑response](jspsych-video-button-response) | Displays a video file with many options for customizing playback. Subject responds to the video by pressing a button.
[jspsych‑video‑keyboard‑response](jspsych-video-keyboard-response) | Displays a video file with many options for customizing playback. Subject responds to the video by pressing a key.
[jspsych‑video‑slider‑response](jspsych-video-slider-response) | Displays a video file with many options for customizing playback. Subject responds to the video by moving a slider.
[jspsych‑visual‑search‑circle](jspsych-visual-search-circle) | A customizable visual-search task modelled after [Wang, Cavanagh, & Green (1994)](http://dx.doi.org/10.3758/BF03206946). The subject indicates whether or not a target is present among a set of distractors. The stimuli are displayed in a circle, evenly-spaced, equidistant from a fixation point.
[jspsych‑vsl‑animate‑occlusion](jspsych-vsl-animate-occlusion) | A visual statistical learning paradigm based on [Fiser & Aslin (2002)](http://dx.doi.org/10.1037//0278-7393.28.3.458). A sequence of stimuli are shown in an oscillatory motion. An occluding rectangle is in the center of the display, and the stimuli change when they are behind the rectangle.
[jspsych‑vsl‑grid‑scene](jspsych-vsl-grid-scene) | A visual statistical learning paradigm based on [Fiser & Aslin (2001)](http://dx.doi.org/10.1111/1467-9280.00392). A scene made up of individual stimuli arranged in a grid is shown. This plugin can also generate the HTML code to render the stimuli for use in other plugins.
[jspsych‑animation](/plugins/jspsych-animation) | Shows a sequence of images at a specified frame rate. Records key presses (including timing information) made by the subject while they are viewing the animation.
[jspsych‑audio‑button‑response](/plugins/jspsych-audio-button-response) | Play an audio file and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑audio‑keyboard‑response](/plugins/jspsych-audio-keyboard-response) | Play an audio file and allow the subject to respond by pressing a key.
[jspsych‑audio‑slider‑response](/plugins/jspsych-audio-slider-response) | Play an audio file and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑call‑function](/plugins/jspsych-call-function) | Executes an arbitrary function call. Doesn't display anything to the subject, and the subject is usually unaware that this plugin has even executed. It's useful for performing tasks at specified times in the experiment, such as saving data.
[jspsych‑canvas‑button‑response](/plugins/jspsych-canvas-button-response) | Draw a stimulus on a [HTML canvas element](https://www.w3schools.com/html/html5_canvas.asp), and record a button click response. Useful for displaying dynamic, parametrically-defined graphics, and for controlling the positioning of multiple graphical elements (shapes, text, images).
[jspsych‑canvas‑keyboard‑response](/plugins/jspsych-canvas-keyboard-response) | Draw a stimulus on a [HTML canvas element](https://www.w3schools.com/html/html5_canvas.asp), and record a key press response. Useful for displaying dynamic, parametrically-defined graphics, and for controlling the positioning of multiple graphical elements (shapes, text, images).
[jspsych‑canvas‑slider‑response](/plugins/jspsych-canvas-slider-response) | Draw a stimulus on a [HTML canvas element](https://www.w3schools.com/html/html5_canvas.asp), and all the subject to respond by moving a slider to indicate a value. Useful for displaying dynamic, parametrically-defined graphics, and for controlling the positioning of multiple graphical elements (shapes, text, images).
[jspsych‑categorize‑animation](/plugins/jspsych-categorize-animation) | The subject responds to an animation and can be given feedback about their response.
[jspsych‑categorize‑html](/plugins/jspsych-categorize-html) | The subject responds to an HTML-formatted stimulus using the keyboard and can be given feedback about the correctness of their response.
[jspsych‑categorize‑image](/plugins/jspsych-categorize-image) | The subject responds to an image using the keyboard and can be given feedback about the correctness of their response.
[jspsych‑cloze](/plugins/jspsych-cloze) | Plugin for displaying a cloze test and checking participants answers against a correct solution.
[jspsych‑external‑html](/plugins/jspsych-external-html) | Displays an external HTML page (such as a consent form) and lets the subject respond by clicking a button or pressing a key. Plugin can validate their response, which is useful for making sure that a subject has granted consent before starting the experiment.
[jspsych‑free‑sort](/plugins/jspsych-free-sort) | Displays a set of images on the screen in random locations. Subjects can click and drag the images to move them around the screen. Records all the moves made by the subject, so the sequence of moves can be recovered from the data.
[jspsych‑fullscreen](/plugins/jspsych-fullscreen) | Toggles the experiment in and out of fullscreen mode.
[jspsych‑html‑button‑response](/plugins/jspsych-html-button-response) | Display an HTML-formatted stimulus and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑html‑keyboard‑response](/plugins/jspsych-html-keyboard-response) | Display an HTML-formatted stimulus and allow the subject to respond by pressing a key.
[jspsych‑html‑slider‑response](/plugins/jspsych-html-slider-response) | Display an HTML-formatted stimulus and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑iat‑html](/plugins/jspsych-iat-html) | The implicit association task, using HTML-formatted stimuli.
[jspsych‑iat‑image](/plugins/jspsych-iat-image) | The implicit association task, using images as stimuli.
[jspsych‑image‑button‑response](/plugins/jspsych-image-button-response) | Display an image and allow the subject to respond by choosing a button to click. The button can be customized extensively, e.g., using images in place of standard buttons.
[jspsych‑image‑keyboard‑response](/plugins/jspsych-image-keyboard-response) | Display an image and allow the subject to respond by pressing a key.
[jspsych‑image‑slider‑response](/plugins/jspsych-image-slider-response) | Display an image and allow the subject to respond by moving a slider to indicate a value.
[jspsych‑maxdiff](/plugins/jspsych-maxdiff) | Displays rows of alternatives to be selected for two mutually-exclusive categories, typically as 'most' or 'least' on a particular criteria (e.g. importance, preference, similarity). The participant responds by selecting one radio button corresponding to an alternative in both the left and right response columns.
[jspsych‑instructions](/plugins/jspsych-instructions) | For displaying instructions to the subject. Allows the subject to navigate between pages of instructions using keys or buttons.
[jspsych‑rdk](/plugins/jspsych-rdk) | This plugin displays a Random Dot Kinematogram (RDK) and allows the subject to report the primary direction of motion by pressing a key on the keyboard.
[jspsych‑reconstruction](/plugins/jspsych-reconstruction) | The subject interacts with a stimulus by modifying a parameter of the stimulus and observing the change in the stimulus in real-time.
[jspsych‑resize](/plugins/jspsych-resize) | Calibrate the display so that materials display with a known physical size.
[jspsych‑same‑different‑html](/plugins/jspsych-same-different-html) | A same-different judgment task. An HTML-formatted stimulus is shown, followed by a brief gap, and then another stimulus is shown. The subject indicates whether the stimuli are the same or different.
[jspsych‑same‑different‑image](/plugins/jspsych-same-different-image) | A same-different judgment task. An image is shown, followed by a brief gap, and then another stimulus is shown. The subject indicates whether the stimuli are the same or different.
[jspsych‑serial‑reaction‑time](/plugins/jspsych-serial-reaction-time) | A set of boxes are displayed on the screen and one of them changes color. The subject presses a key that corresponds to the different color box as fast as possible.
[jspsych‑serial‑reaction‑time‑mouse](/plugins/jspsych-serial-reaction-time-mouse) | A set of boxes are displayed on the screen and one of them changes color. The subjects clicks the box that changed color as fast as possible.
[jspsych‑survey‑html‑form](/plugins/jspsych-survey-html-form) | Renders a custom HTML form. Allows for mixing multiple kinds of form input.
[jspsych‑survey‑likert](/plugins/jspsych-survey-likert) | Displays likert-style questions.
[jspsych‑survey‑multi‑choice](/plugins/jspsych-survey-multi-choice) | Displays multiple choice questions with one answer allowed per question.
[jspsych‑survey‑multi‑select](/plugins/jspsych-survey-multi-select) | Displays multiple choice questions with multiple answes allowed per question.
[jspsych‑survey‑text](/plugins/jspsych-survey-text) | Shows a prompt with a text box. The subject writes a response and then submits by clicking a button.
[jspsych‑video‑button‑response](/plugins/jspsych-video-button-response) | Displays a video file with many options for customizing playback. Subject responds to the video by pressing a button.
[jspsych‑video‑keyboard‑response](/plugins/jspsych-video-keyboard-response) | Displays a video file with many options for customizing playback. Subject responds to the video by pressing a key.
[jspsych‑video‑slider‑response](/plugins/jspsych-video-slider-response) | Displays a video file with many options for customizing playback. Subject responds to the video by moving a slider.
[jspsych‑visual‑search‑circle](/plugins/jspsych-visual-search-circle) | A customizable visual-search task modelled after [Wang, Cavanagh, & Green (1994)](http://dx.doi.org/10.3758/BF03206946). The subject indicates whether or not a target is present among a set of distractors. The stimuli are displayed in a circle, evenly-spaced, equidistant from a fixation point.
[jspsych‑vsl‑animate‑occlusion](/plugins/jspsych-vsl-animate-occlusion) | A visual statistical learning paradigm based on [Fiser & Aslin (2002)](http://dx.doi.org/10.1037//0278-7393.28.3.458). A sequence of stimuli are shown in an oscillatory motion. An occluding rectangle is in the center of the display, and the stimuli change when they are behind the rectangle.
[jspsych‑vsl‑grid‑scene](/plugins/jspsych-vsl-grid-scene) | A visual statistical learning paradigm based on [Fiser & Aslin (2001)](http://dx.doi.org/10.1111/1467-9280.00392). A scene made up of individual stimuli arranged in a grid is shown. This plugin can also generate the HTML code to render the stimuli for use in other plugins.

View File

@ -2419,16 +2419,6 @@ jsPsych.pluginAPI = (function() {
}
audio.removeEventListener('error', handleError);
});
audio.addEventListener('stalled', function handleStalled(){
if(count < jsPsych.initSettings().max_preload_attempts){
setTimeout(function(){
load_audio_file_html5audio(source, count+1)
}, 200);
} else {
jsPsych.loadFail();
}
audio.removeEventListener('stalled', handleStalled);
});
audio.addEventListener('abort', function handleAbort(){
if(count < jsPsych.initSettings().max_preload_attempts){
setTimeout(function(){
@ -2637,7 +2627,10 @@ jsPsych.pluginAPI = (function() {
loaded++;
if(progress_bar){
var percent_loaded = (loaded/total_n)*100;
jsPsych.getDisplayElement().querySelector('#jspsych-loading-progress-bar').style.width = percent_loaded+"%";
var preload_progress_bar = jsPsych.getDisplayElement().querySelector('#jspsych-loading-progress-bar');
if (preload_progress_bar !== null) {
preload_progress_bar.style.width = percent_loaded+"%";
}
}
}

View File

@ -9,11 +9,11 @@ theme:
favicon: 'img/jspsych-favicon.png'
extra:
social:
- type: 'github'
- icon: 'fontawesome/brands/github'
link: 'https://github.com/jspsych'
- type: 'twitter'
- icon: 'fontawesome/brands/twitter'
link: 'https://twitter.com/joshdeleeuw'
copyright: 'Copyright &copy; 2012-2019 Josh de Leeuw'
copyright: 'Copyright &copy; 2012-2020 Josh de Leeuw'
google_analytics:
- 'UA-50563838-1'
- 'auto'
@ -35,6 +35,7 @@ nav:
- 'Creating an Experiment: The Timeline': 'overview/timeline.md'
- 'Advanced Options for Trials': 'overview/trial.md'
- 'Data Storage, Aggregation, and Manipulation': 'overview/data.md'
- 'Collecting Data from Online Participants': 'overview/collecting-data.md'
- 'Experiment Settings': 'overview/experiment-options.md'
- 'Event-related Callback Functions': 'overview/callbacks.md'
- 'Record Browser Interactions': 'overview/record-browser-interactions.md'
@ -43,7 +44,8 @@ nav:
- 'Exclude Participants Based on Browser Features': 'overview/exclude-browser.md'
- 'Automatic Progress Bar': 'overview/progress-bar.md'
- 'Integrating with Mechanical Turk': 'overview/mturk.md'
- Core Library API:
- 'Browser and Device Support': 'overview/browser-device-support.md'
- Reference:
- 'jsPsych': 'core_library/jspsych-core.md'
- 'jsPsych.data': 'core_library/jspsych-data.md'
- 'jsPsych.randomization': 'core_library/jspsych-randomization.md'
@ -56,6 +58,9 @@ nav:
- 'jspsych-audio-button-response': 'plugins/jspsych-audio-button-response.md'
- 'jspsych-audio-keyboard-response': 'plugins/jspsych-audio-keyboard-response.md'
- 'jspsych-audio-slider-response': 'plugins/jspsych-audio-slider-response.md'
- 'jspsych-canvas-button-response': 'plugins/jspsych-canvas-button-response.md'
- 'jspsych-canvas-keyboard-response': 'plugins/jspsych-canvas-keyboard-response.md'
- 'jspsych-canvas-slider-response': 'plugins/jspsych-canvas-slider-response.md'
- 'jspsych-call-function': 'plugins/jspsych-call-function.md'
- 'jspsych-categorize-animation': 'plugins/jspsych-categorize-animation.md'
- 'jspsych-categorize-html': 'plugins/jspsych-categorize-html.md'
@ -73,6 +78,7 @@ nav:
- 'jspsych-image-keyboard-response': 'plugins/jspsych-image-keyboard-response.md'
- 'jspsych-image-slider-response': 'plugins/jspsych-image-slider-response.md'
- 'jspsych-instructions': 'plugins/jspsych-instructions.md'
- 'jspsych-maxdiff': 'plugins/jspsych-maxdiff.md'
- 'jspsych-rdk': 'plugins/jspsych-rdk.md'
- 'jspsych-reconstruction': 'plugins/jspsych-reconstruction.md'
- 'jspsych-resize': 'plugins/jspsych-resize.md'

View File

@ -6,16 +6,18 @@ describe('video-button-response plugin', function(){
beforeEach(function(){
require(root + 'jspsych.js');
require(root + 'plugins/jspsych-video-button-response.js');
// don't load plugin here - need to spy on registerPreload before its called
});
test('loads correctly', function(){
require(root + 'plugins/jspsych-video-button-response.js');
expect(typeof window.jsPsych.plugins['video-button-response']).not.toBe('undefined');
});
test('video preloading initiates automatically', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-button-response.js');
var trial = {
type: 'video-button-response',
stimulus: [root + 'tests/media/sample_video.mp4'],
@ -24,7 +26,7 @@ describe('video-button-response plugin', function(){
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();

View File

@ -6,16 +6,18 @@ describe('video-keyboard-response plugin', function(){
beforeEach(function(){
require(root + 'jspsych.js');
require(root + 'plugins/jspsych-video-keyboard-response.js');
// don't load plugin here - need to spy on registerPreload before its called
});
test('loads correctly', function(){
require(root + 'plugins/jspsych-video-keyboard-response.js');
expect(typeof window.jsPsych.plugins['video-keyboard-response']).not.toBe('undefined');
});
test('video preloading initiates automatically', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-keyboard-response.js');
var trial = {
type: 'video-keyboard-response',
stimulus: [root + 'tests/media/sample_video.mp4'],
@ -24,7 +26,7 @@ describe('video-keyboard-response plugin', function(){
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();

View File

@ -6,16 +6,18 @@ describe('video-slider-response plugin', function(){
beforeEach(function(){
require(root + 'jspsych.js');
require(root + 'plugins/jspsych-video-slider-response.js');
// don't load plugin here - need to spy on registerPreload before its called
});
test('loads correctly', function(){
require(root + 'plugins/jspsych-video-slider-response.js');
expect(typeof window.jsPsych.plugins['video-slider-response']).not.toBe('undefined');
});
test('video preloading initiates automatically', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-slider-response.js');
var trial = {
type: 'video-slider-response',
stimulus: [root + 'tests/media/sample_video.mp4']
@ -23,7 +25,7 @@ describe('video-slider-response plugin', function(){
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();