Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from brown-ccv/develop
Browse files Browse the repository at this point in the history
fix: tests
  • Loading branch information
Rashi1997 authored Feb 7, 2021
2 parents 2c099c1 + 4905c98 commit 34deb39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions tests/showMessage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
});
});
4 changes: 2 additions & 2 deletions trials/showMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();

Expand Down

0 comments on commit 34deb39

Please sign in to comment.