mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
tests for #350 for now
This commit is contained in:
parent
5d4029aa58
commit
0a09b3e7ab
@ -25,9 +25,7 @@ describe('Data recording', function(){
|
||||
{type: 'text', text:'hello'}
|
||||
];
|
||||
jsPsych.init({timeline:timeline});
|
||||
console.log(jsPsych.data.getInteractionData().json())
|
||||
window.dispatchEvent(new Event('blur'));
|
||||
console.log(jsPsych.data.getInteractionData().json())
|
||||
// click through first trial
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keyup', {keyCode: 32}));
|
||||
@ -80,15 +78,14 @@ describe('on_interaction_data_update', function(){
|
||||
on_interaction_data_update: updatefn
|
||||
});
|
||||
window.dispatchEvent(new Event('blur'));
|
||||
console.log(jsPsych.data.getInteractionData().json())
|
||||
expect(updatefn.mock.calls.length).toBe(1);
|
||||
expect(updatefn.mock.calls.length).toBeGreaterThanOrEqual(1); // >= because of jsdom window not isolated to this test.
|
||||
|
||||
// click through first trial
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keyup', {keyCode: 32}));
|
||||
// check data
|
||||
});
|
||||
|
||||
test.only('fires for focus', function(){
|
||||
test('fires for focus', function(){
|
||||
var updatefn = jest.fn();
|
||||
|
||||
var timeline = [
|
||||
@ -99,12 +96,10 @@ describe('on_interaction_data_update', function(){
|
||||
on_interaction_data_update: updatefn
|
||||
});
|
||||
window.dispatchEvent(new Event('focus'));
|
||||
console.log(jsPsych.data.getInteractionData().json())
|
||||
expect(updatefn.mock.calls.length).toBe(1);
|
||||
expect(updatefn.mock.calls.length).toBeGreaterThanOrEqual(1); // >= because of jsdom window not isolated to this test.
|
||||
// click through first trial
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
|
||||
document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keyup', {keyCode: 32}));
|
||||
// check data
|
||||
})
|
||||
|
||||
/* not sure yet how to test fullscreen events with jsdom engine */
|
||||
|
Loading…
Reference in New Issue
Block a user