From 0a09b3e7ab14e059d8aa7c974af998f2cdab05b8 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Mon, 12 Jun 2017 22:08:17 -0400 Subject: [PATCH] tests for #350 for now --- tests/jsPsych.data/interactions.test.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/jsPsych.data/interactions.test.js b/tests/jsPsych.data/interactions.test.js index cd02e099..cf114fe6 100644 --- a/tests/jsPsych.data/interactions.test.js +++ b/tests/jsPsych.data/interactions.test.js @@ -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 */