mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
add .endCurrentTimeline test
This commit is contained in:
parent
e4e03269fa
commit
844ea6f1db
@ -230,4 +230,37 @@ describe('conditional function', function(){
|
|||||||
|
|
||||||
describe('endCurrentTimeline', function(){
|
describe('endCurrentTimeline', function(){
|
||||||
|
|
||||||
|
test('stops the current timeline, skipping to the end after the trial completes', function(){
|
||||||
|
var t = {
|
||||||
|
timeline: [
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
text: 'foo',
|
||||||
|
on_finish: function(){
|
||||||
|
jsPsych.endCurrentTimeline();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
text: 'bar',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [t, {type: 'text', text: 'woo'}]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toBe('foo');
|
||||||
|
|
||||||
|
document.dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
|
||||||
|
document.dispatchEvent(new KeyboardEvent('keyup', {keyCode: 32}));
|
||||||
|
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toBe('woo');
|
||||||
|
|
||||||
|
document.dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
|
||||||
|
document.dispatchEvent(new KeyboardEvent('keyup', {keyCode: 32}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user