add a test case for survey-text defaults

This commit is contained in:
Josh de Leeuw 2018-03-11 17:06:28 -04:00
parent a4b3271b09
commit f2319fec53

View File

@ -1,4 +1,5 @@
const root = '../../'; const root = '../../';
const utils = require('../testing-utils.js');
jest.useFakeTimers(); jest.useFakeTimers();
@ -13,4 +14,23 @@ describe('survey-text plugin', function(){
expect(typeof window.jsPsych.plugins['survey-text']).not.toBe('undefined'); expect(typeof window.jsPsych.plugins['survey-text']).not.toBe('undefined');
}); });
test('default parameters work correctly', function(){
var trial = {
type: 'survey-text',
questions: [{prompt: "How old are you?"}, {prompt: "Where were you born?"}]
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().querySelectorAll('p.jspsych-survey-text').length).toBe(2);
expect(jsPsych.getDisplayElement().querySelector('input[name="#jspsych-survey-text-response-0"]').size).toBe(40);
expect(jsPsych.getDisplayElement().querySelector('input[name="#jspsych-survey-text-response-1"]').size).toBe(40);
utils.clickTarget(document.querySelector('#jspsych-survey-text-next'));
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
});
}); });