add test for nested timelines and endCurrentTimeline (#600)

This commit is contained in:
Josh de Leeuw 2019-05-30 16:50:02 -04:00
parent 4a5a310e79
commit 8c998ef249

View File

@ -253,4 +253,51 @@ describe('endCurrentTimeline', function(){
}); });
test('works inside nested timelines', function(){
var t = {
timeline: [
{
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'foo',
on_finish: function(){
jsPsych.endCurrentTimeline();
}
},
{
type: 'html-keyboard-response',
stimulus: 'skip me!'
}
]
},
{
type: 'html-keyboard-response',
stimulus: 'bar'
}
]
}
var t2 = {
type: 'html-keyboard-response',
stimulus: 'woo'
}
jsPsych.init({
timeline: [t, t2]
});
expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo');
utils.pressKey(32);
expect(jsPsych.getDisplayElement().innerHTML).toMatch('bar');
utils.pressKey(32);
expect(jsPsych.getDisplayElement().innerHTML).toMatch('woo');
utils.pressKey(32);
})
}); });