image-slider-response test

This commit is contained in:
KristinDiep 2017-07-07 16:48:49 -04:00
parent 13930f9e40
commit 3d161376af
2 changed files with 119 additions and 2 deletions

View File

@ -104,8 +104,7 @@ describe('image-button-response', function(){
});
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-button-response-stimulus').style.visibility).toMatch("");
jest.runTimersToTime(500);
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-button-response-stimulus').style.visibility).toMatch("hidden");
5
});
test('should end trial when trial duration is reached', function(){

View File

@ -27,4 +27,122 @@ describe('image-slider-response', function(){
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<div id="jspsych-image-slider-response-stimulus"><img src="../media/blue.png"></div>');
});
test('displays labels', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<span style=\"text-align: center; font-size: 80%;\">left</span>');
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<span style=\"text-align: center; font-size: 80%;\">right</span>');
})
test('displays button label', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
button_label: 'button'
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<button id=\"jspsych-image-slider-response-next\" class=\"jspsych-btn\">button</button>');
});
test('should set min, max and step', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
min: 2,
max: 10,
step: 2,
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-slider-response-response').min).toBe('2');
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-slider-response-response').max).toBe('10');
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-slider-response-response').step).toBe('2');
});
test('should append to bottom on stimulus', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
prompt: '<p>This is a prompt</p>'
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<p>This is a prompt</p>');
});
test('should hide stimulus if stimulus_duration is set', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
stimulus_duration: 500
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-slider-response-stimulus').style.visibility).toMatch("");
jest.runTimersToTime(500);
expect(jsPsych.getDisplayElement().querySelector('#jspsych-image-slider-response-stimulus').style.visibility).toMatch("hidden");
});
test('should end trial when trial duration is reached', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
trial_duration: 500
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<div id="jspsych-image-slider-response-stimulus"><img src="../media/blue.png"></div>');
jest.runTimersToTime(500);
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
});
test('should end trial when button is clicked', function(){
var trial = {
type: 'image-slider-response',
stimulus: '../media/blue.png',
labels: ['left', 'right'],
response_ends_trial: true
}
jsPsych.init({
timeline: [trial]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('<div id="jspsych-image-slider-response-stimulus"><img src="../media/blue.png"></div>');
utils.clickTarget(document.querySelector('#jspsych-image-slider-response-next'));
expect(jsPsych.getDisplayElement().innerHTML).toBe('');
});
});