add broken test to illustrate problem in #585

This commit is contained in:
Josh de Leeuw 2020-12-16 11:05:48 -05:00
parent b8225d7add
commit 983810145b

View File

@ -399,6 +399,57 @@ describe('on_timeline_finish', function(){
expect(on_finish_fn).not.toHaveBeenCalled();
utils.pressKey(32);
expect(on_finish_fn).toHaveBeenCalled();
});
test('should fire once even with timeline variables', function(){
var on_finish_fn = jest.fn();
var tvs = [{
x: 1,
x: 2,
}]
var mini_timeline = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'foo'
}
],
on_timeline_finish: on_finish_fn,
timeline_variables: tvs
}
jsPsych.init({timeline: [mini_timeline]});
utils.pressKey(32);
utils.pressKey(32);
expect(on_finish_fn.mock.calls.length).toBe(1);
})
test('should fire once even with repetitions', function(){
var on_finish_fn = jest.fn();
var mini_timeline = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'foo'
}
],
on_timeline_finish: on_finish_fn,
repetitions: 2
}
jsPsych.init({timeline: [mini_timeline]});
utils.pressKey(32);
utils.pressKey(32);
expect(on_finish_fn.mock.calls.length).toBe(1);
})
})
@ -434,4 +485,57 @@ describe('on_timeline_start', function(){
expect(on_start_fn.mock.calls.length).toBe(1);
})
test('should fire once even with timeline variables', function(){
var on_start_fn = jest.fn();
var tvs = [{
x: 1,
x: 2,
}]
var mini_timeline = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'foo'
}
],
on_timeline_start: on_start_fn,
timeline_variables: tvs
}
jsPsych.init({timeline: [mini_timeline]});
expect(on_start_fn).toHaveBeenCalled();
utils.pressKey(32);
utils.pressKey(32);
expect(on_start_fn.mock.calls.length).toBe(1);
})
test('should fire once even with repetitions', function(){
var on_start_fn = jest.fn();
var mini_timeline = {
timeline: [
{
type: 'html-keyboard-response',
stimulus: 'foo'
}
],
on_timeline_start: on_start_fn,
repetitions: 2
}
jsPsych.init({timeline: [mini_timeline]});
expect(on_start_fn).toHaveBeenCalled();
utils.pressKey(32);
utils.pressKey(32);
expect(on_start_fn.mock.calls.length).toBe(1);
})
})