mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
add a test to ensure loop function runs only once with TVs #585
This commit is contained in:
parent
8dd61e6bed
commit
7dbcfea7da
@ -166,6 +166,36 @@ describe('loop function', function(){
|
|||||||
utils.pressKey(32);
|
utils.pressKey(32);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('only runs once when timeline variables are used', function(){
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
var trial = {
|
||||||
|
timeline: [{
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo'
|
||||||
|
}],
|
||||||
|
timeline_variables:[{a:1},{a:2}],
|
||||||
|
loop_function: function(){
|
||||||
|
count++;
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [trial]
|
||||||
|
});
|
||||||
|
|
||||||
|
// first trial
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(count).toBe(0);
|
||||||
|
|
||||||
|
// second trial
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
expect(count).toBe(1);
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('conditional function', function(){
|
describe('conditional function', function(){
|
||||||
|
Loading…
Reference in New Issue
Block a user