mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
add new progress bar tests
This commit is contained in:
parent
954eac9784
commit
8b8d269665
@ -137,4 +137,66 @@ describe('automatic progress bar', function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getProgressBarCompleted() -- manual updates', function(){
|
||||||
|
var trial = {
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo',
|
||||||
|
on_finish: function(){
|
||||||
|
jsPsych.setProgressBar(0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var trial_2 = {
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo',
|
||||||
|
on_finish: function(){
|
||||||
|
jsPsych.setProgressBar(0.8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [trial, trial_2],
|
||||||
|
show_progress_bar: true,
|
||||||
|
auto_update_progress_bar: false
|
||||||
|
});
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(0.2);
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(0.8);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getProgressBarCompleted() -- automatic updates', function(){
|
||||||
|
var trial = {
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo'
|
||||||
|
}
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [trial, trial, trial, trial],
|
||||||
|
show_progress_bar: true
|
||||||
|
});
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(0.25);
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(0.50);
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(0.75);
|
||||||
|
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(jsPsych.getProgressBarCompleted()).toBe(1);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user