diff --git a/tests/showMessage.spec.js b/tests/showMessage.spec.js index aa81f73..c880d2e 100644 --- a/tests/showMessage.spec.js +++ b/tests/showMessage.spec.js @@ -6,7 +6,7 @@ describe('showMessage trial', () => { it('showMessage without photodiode box', () => { const config = init({USE_PHOTODIODE: false}); const message = 'Experiment Start' - const result = showMessage('html_keyboard_response',100, config, message, false); + const result = showMessage('html_keyboard_response',100, config, message, false, false); expect(result.stimulus).toContain(message); expect(result.stimulus).not.toContain('photodiode-spot'); expect(result.on_load()).toEqual(null); @@ -18,7 +18,7 @@ describe('showMessage trial', () => { const config = init({USE_PHOTODIODE: true}); const message = 'Experiment Start' let data = { code: null } - const result = showMessage('html_keyboard_response',100, config, message, false,10,10); + const result = showMessage('html_keyboard_response',100, config, message, false, false,10,10); expect(result.stimulus).toContain(message); expect(result.stimulus).toContain('photodiode-spot'); expect(result.on_load()).not.toEqual(null); @@ -27,14 +27,22 @@ describe('showMessage trial', () => { it('showMessage with jsPsych.NO_KEYS', () => { const config = init({USE_PHOTODIODE: false}); - const result = showMessage('html_button_response',100, config, false, undefined, undefined, undefined, jsPsych.NO_KEYS); + const result = showMessage('html_button_response',100, config, '', false, undefined, undefined, undefined, jsPsych.NO_KEYS); expect(result.choices).toEqual(undefined); }); it('showMessage with choices', () => { const config = init({USE_PHOTODIODE: false}); const choices = ['p','q'] - const result = showMessage('html_button_response',100, config, false, undefined, undefined, undefined, choices); + const result = showMessage('html_button_response',100, config, '', false, undefined, undefined, undefined, choices); expect(result.choices).toEqual(choices); }); + + it('showMessage with on start message', () => { + const config = init({USE_PHOTODIODE: false}); + const message = 'Experiment Start' + let trial = { stimulus: null } + const result = showMessage('html_button_response',100, config, message, true, false,10,10); + expect(result.on_start(trial)).not.toEqual(null); + }); }); \ No newline at end of file diff --git a/trials/showMessage.js b/trials/showMessage.js index 7affb8c..ea27cb0 100644 --- a/trials/showMessage.js +++ b/trials/showMessage.js @@ -8,7 +8,7 @@ const { baseStimulus } = require('../lib/markup/stimuli') * @param {number} duration - The trial duration in milliseconds. * @param {object} config - The configuration object for USE_PHOTODIODE, IS_ELECTRON and USE_MTURK flags. * @param {string} message - Onscreen message to be shown in the trial, if not set default text is empty. - * @param {boolean} onstart - True if the message is to be display on start of the trial. False if the message needs to be in the stimulus. + * @param {boolean} onstart - True if the message is to be display on start of the trial. False if the message needs to be in the stimulus.(default: false) * @param {boolean} responseEndsTrial - True if the trial ends on response,false if the trial waits for the duration, by default false value. * @param {number} taskCode - Task code to be saved into data log and for pdSpotEncode, which by default is null and is passed when config has USE_PHOTODIODE set true. * @param {number} numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. If not set, by default is 1. @@ -17,7 +17,7 @@ const { baseStimulus } = require('../lib/markup/stimuli') module.exports = - function(responseType, duration, config, message = "", responseEndsTrial = false, taskCode = null, numBlinks = 1, buttons) { + function(responseType, duration, config, message = "", onstart= false, responseEndsTrial = false, taskCode = null, numBlinks = 1, buttons) { let stimulus = baseStimulus(`${message}`, true) if(config.USE_PHOTODIODE) stimulus += photodiodeGhostBox();