added tests for trial deadlock

This commit is contained in:
Becky Gilbert 2020-10-16 18:03:02 -07:00
parent d6f3d79d04
commit 5050d636a4
2 changed files with 39 additions and 0 deletions

View File

@ -151,4 +151,23 @@ describe('image-button-response', function(){
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
});
test('should show console warning when trial duration is null and response ends trial is false', function() {
var trial = {
type: 'image-button-response',
stimulus: '../media/blue.png',
choices: ['button-choice'],
response_ends_trial: false,
trial_duration: null
};
jsPsych.init({
timeline: [trial],
auto_preload: false
});
spy = jest.spyOn(console, 'warn').mockImplementation();
expect(console.warn).toHaveBeenCalledWith("The experiment may be stuck in a loop. Try setting a trial duration or set response_ends_trial to true.");
spy.mockRestore();
});
});

View File

@ -123,4 +123,24 @@ describe('image-keyboard-response', function(){
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
});
test('should show console warning when trial duration is null and response ends trial is false', function() {
var trial = {
type: 'image-keyboard-response',
stimulus: '../media/blue.png',
choices: ['f','j'],
response_ends_trial: false,
trial_duration: null
};
jsPsych.init({
timeline: [trial],
auto_preload: false
});
spy = jest.spyOn(console, 'warn').mockImplementation();
expect(console.warn).toHaveBeenCalledWith("The experiment may be stuck in a loop. Try setting a trial duration or set response_ends_trial to true.");
spy.mockRestore();
});
});