mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
add test for nested timelines and endCurrentTimeline (#600)
This commit is contained in:
parent
4a5a310e79
commit
8c998ef249
@ -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);
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user