diff --git a/tests/plugins/plugin-image-button-response.test.js b/tests/plugins/plugin-image-button-response.test.js index fb5eade5..b2a9d038 100644 --- a/tests/plugins/plugin-image-button-response.test.js +++ b/tests/plugins/plugin-image-button-response.test.js @@ -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(); + }); }); diff --git a/tests/plugins/plugin-image-keyboard-response.test.js b/tests/plugins/plugin-image-keyboard-response.test.js index f34ee76d..c362a1db 100644 --- a/tests/plugins/plugin-image-keyboard-response.test.js +++ b/tests/plugins/plugin-image-keyboard-response.test.js @@ -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(); + }); });