video tests just check that register preload is called, no longer test for auto-preloading

This commit is contained in:
Becky Gilbert 2021-02-11 14:24:29 -08:00
parent 301b4cb788
commit 9729cd99ef
3 changed files with 6 additions and 15 deletions

View File

@ -14,22 +14,19 @@ describe('video-button-response plugin', function(){
expect(typeof window.jsPsych.plugins['video-button-response']).not.toBe('undefined'); expect(typeof window.jsPsych.plugins['video-button-response']).not.toBe('undefined');
}); });
test('video preloading initiates automatically', function(){ test('video preloading registers correctly', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload'); const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-button-response.js'); require(root + 'plugins/jspsych-video-button-response.js');
var trial = { var trial = {
type: 'video-button-response', type: 'video-button-response',
stimulus: [root + 'tests/media/sample_video.mp4'], stimulus: ['vid.mp4'],
choices: ['y'] choices: ['y']
} }
jsPsych.init({ jsPsych.init({
timeline: [trial] timeline: [trial]
}); });
expect(preload_spy).toHaveBeenCalled(); expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalledWith('jsPsych failed to auto preload one or more files:');
preload_spy.mockRestore(); preload_spy.mockRestore();
console_spy.mockRestore();
}); });
}); });

View File

@ -14,22 +14,19 @@ describe('video-keyboard-response plugin', function(){
expect(typeof window.jsPsych.plugins['video-keyboard-response']).not.toBe('undefined'); expect(typeof window.jsPsych.plugins['video-keyboard-response']).not.toBe('undefined');
}); });
test('video preloading initiates automatically', function(){ test('video preloading registers correctly', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload'); const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-keyboard-response.js'); require(root + 'plugins/jspsych-video-keyboard-response.js');
var trial = { var trial = {
type: 'video-keyboard-response', type: 'video-keyboard-response',
stimulus: [root + 'tests/media/sample_video.mp4'], stimulus: ['video.mp4'],
choices: jsPsych.ALL_KEYS choices: jsPsych.ALL_KEYS
} }
jsPsych.init({ jsPsych.init({
timeline: [trial] timeline: [trial]
}); });
expect(preload_spy).toHaveBeenCalled(); expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalledWith('jsPsych failed to auto preload one or more files:');
preload_spy.mockRestore(); preload_spy.mockRestore();
console_spy.mockRestore();
}); });
}); });

View File

@ -14,21 +14,18 @@ describe('video-slider-response plugin', function(){
expect(typeof window.jsPsych.plugins['video-slider-response']).not.toBe('undefined'); expect(typeof window.jsPsych.plugins['video-slider-response']).not.toBe('undefined');
}); });
test('video preloading initiates automatically', function(){ test('video preloading registers correctly', function(){
const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload'); const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload');
const console_spy = jest.spyOn(console, 'warn');
require(root + 'plugins/jspsych-video-slider-response.js'); require(root + 'plugins/jspsych-video-slider-response.js');
var trial = { var trial = {
type: 'video-slider-response', type: 'video-slider-response',
stimulus: [root + 'tests/media/sample_video.mp4'] stimulus: ['video.mp4']
} }
jsPsych.init({ jsPsych.init({
timeline: [trial] timeline: [trial]
}); });
expect(preload_spy).toHaveBeenCalled(); expect(preload_spy).toHaveBeenCalled();
expect(console_spy).not.toHaveBeenCalledWith('jsPsych failed to auto preload one or more files:');
preload_spy.mockRestore(); preload_spy.mockRestore();
console_spy.mockRestore();
}); });
}); });