add auto preload test

This commit is contained in:
Becky Gilbert 2020-12-02 12:11:38 -08:00
parent ffc80a372e
commit b67d4a4881
3 changed files with 50 additions and 0 deletions

View File

@ -13,4 +13,21 @@ describe('video-button-response plugin', function(){
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');
var trial = {
type: 'video-button-response',
stimulus: [root + 'tests/media/sample_video.mp4'],
choices: ['y']
}
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();
});
});

View File

@ -13,4 +13,21 @@ describe('video-keyboard-response plugin', function(){
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');
var trial = {
type: 'video-keyboard-response',
stimulus: [root + 'tests/media/sample_video.mp4'],
choices: jsPsych.ALL_KEYS
}
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();
});
});

View File

@ -13,4 +13,20 @@ describe('video-slider-response plugin', function(){
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');
var trial = {
type: 'video-slider-response',
stimulus: [root + 'tests/media/sample_video.mp4']
}
jsPsych.init({
timeline: [trial]
});
//expect(preload_spy).toHaveBeenCalled(); // NOT WORKING
expect(console_spy).not.toHaveBeenCalled();
preload_spy.mockRestore();
console_spy.mockRestore();
});
});