From 7e288d448151daf619fb5f03a72925f279bcc380 Mon Sep 17 00:00:00 2001 From: Becky Gilbert Date: Tue, 9 Feb 2021 15:29:02 -0800 Subject: [PATCH] change keyCodes to keys in calls to utils.pressKey() --- tests/jsPsych/css-classes-parameter.test.js | 12 ++++---- tests/jsPsych/events.test.js | 28 +++++++++---------- tests/jsPsych/functions-as-parameters.test.js | 8 +++--- tests/jsPsych/timeline-variables.test.js | 28 +++++++++---------- tests/jsPsych/timelines.test.js | 12 ++++---- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/jsPsych/css-classes-parameter.test.js b/tests/jsPsych/css-classes-parameter.test.js index 9c7e9c10..47b6d0cc 100644 --- a/tests/jsPsych/css-classes-parameter.test.js +++ b/tests/jsPsych/css-classes-parameter.test.js @@ -18,7 +18,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[trial]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); }) test('Gracefully handles single class when not in array', function(){ @@ -31,7 +31,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[trial]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); }) test('Removes the added classes at the end of the trial', function(){ @@ -44,7 +44,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[trial]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false); }) @@ -61,7 +61,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[tm]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false); }) @@ -78,7 +78,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[trial]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false); }) @@ -100,7 +100,7 @@ describe('The css_classes parameter for trials', function(){ jsPsych.init({timeline:[t]}); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true); - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false); }) diff --git a/tests/jsPsych/events.test.js b/tests/jsPsych/events.test.js index d88cd6a1..5d183891 100644 --- a/tests/jsPsych/events.test.js +++ b/tests/jsPsych/events.test.js @@ -393,11 +393,11 @@ describe('on_timeline_finish', function(){ jsPsych.init({timeline: [mini_timeline]}); - utils.pressKey(32); + utils.pressKey('a'); expect(on_finish_fn).not.toHaveBeenCalled(); - utils.pressKey(32); + utils.pressKey('a'); expect(on_finish_fn).not.toHaveBeenCalled(); - utils.pressKey(32); + utils.pressKey('a'); expect(on_finish_fn).toHaveBeenCalled(); }); @@ -423,8 +423,8 @@ describe('on_timeline_finish', function(){ jsPsych.init({timeline: [mini_timeline]}); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); expect(on_finish_fn.mock.calls.length).toBe(1); }) @@ -446,8 +446,8 @@ describe('on_timeline_finish', function(){ jsPsych.init({timeline: [mini_timeline]}); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); expect(on_finish_fn.mock.calls.length).toBe(2); }) @@ -479,9 +479,9 @@ describe('on_timeline_start', function(){ jsPsych.init({timeline: [mini_timeline]}); expect(on_start_fn).toHaveBeenCalled(); - utils.pressKey(32); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); + utils.pressKey('a'); expect(on_start_fn.mock.calls.length).toBe(1); }) @@ -509,8 +509,8 @@ describe('on_timeline_start', function(){ jsPsych.init({timeline: [mini_timeline]}); expect(on_start_fn).toHaveBeenCalled(); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); expect(on_start_fn.mock.calls.length).toBe(1); }) @@ -533,8 +533,8 @@ describe('on_timeline_start', function(){ jsPsych.init({timeline: [mini_timeline]}); expect(on_start_fn).toHaveBeenCalled(); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); expect(on_start_fn.mock.calls.length).toBe(2); }) diff --git a/tests/jsPsych/functions-as-parameters.test.js b/tests/jsPsych/functions-as-parameters.test.js index 8bba026b..0a536f66 100644 --- a/tests/jsPsych/functions-as-parameters.test.js +++ b/tests/jsPsych/functions-as-parameters.test.js @@ -21,7 +21,7 @@ describe('standard use of function as parameter', function(){ }) expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo'); - utils.pressKey(32); + utils.pressKey('a'); }); test('function evaluates at runtime', function(){ @@ -41,7 +41,7 @@ describe('standard use of function as parameter', function(){ }) expect(jsPsych.getDisplayElement().innerHTML).toMatch('bar'); - utils.pressKey(32); + utils.pressKey('a'); }) }) @@ -60,7 +60,7 @@ describe('data as function', function(){ timeline: [trial] }) - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.data.get().values()[0].x).toBe(1) }) @@ -78,7 +78,7 @@ describe('data as function', function(){ timeline: [trial] }) - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.data.get().values()[0].x).toBe(1) }) }) diff --git a/tests/jsPsych/timeline-variables.test.js b/tests/jsPsych/timeline-variables.test.js index 59ec40eb..f48a2267 100644 --- a/tests/jsPsych/timeline-variables.test.js +++ b/tests/jsPsych/timeline-variables.test.js @@ -273,7 +273,7 @@ describe('timeline variables are correctly evaluated', function(){ }) expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo'); - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.getDisplayElement().innerHTML).toMatch('bar'); }); @@ -303,7 +303,7 @@ describe('timeline variables are correctly evaluated', function(){ }) - utils.pressKey(32); + utils.pressKey('a'); expect(x).toBe('foo'); }) @@ -333,7 +333,7 @@ describe('timeline variables are correctly evaluated', function(){ }) - utils.pressKey(32); + utils.pressKey('a'); expect(x).toBe('foo'); }) @@ -360,7 +360,7 @@ describe('timeline variables are correctly evaluated', function(){ }) - utils.pressKey(32); + utils.pressKey('a'); expect(jsPsych.data.get().values()[0].x).toBe('foo'); }) @@ -389,7 +389,7 @@ describe('timeline variables are correctly evaluated', function(){ }) - utils.pressKey(32); + utils.pressKey('a'); expect(x).toBe('foo'); }) @@ -418,7 +418,7 @@ describe('timeline variables are correctly evaluated', function(){ }) - utils.pressKey(32); + utils.pressKey('a'); expect(x).toBe('foo'); }) @@ -443,8 +443,8 @@ describe('jsPsych.allTimelineVariables()', function(){ jsPsych.init({timeline: [t]}); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); var data = jsPsych.data.get().values(); expect(data[0].a).toBe(1); @@ -479,10 +479,10 @@ describe('jsPsych.allTimelineVariables()', function(){ jsPsych.init({timeline: [t2]}); - utils.pressKey(32); - utils.pressKey(32); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); + utils.pressKey('a'); + utils.pressKey('a'); var data = jsPsych.data.get().values(); @@ -523,8 +523,8 @@ describe('jsPsych.allTimelineVariables()', function(){ jsPsych.init({timeline: [t]}); - utils.pressKey(32); - utils.pressKey(32); + utils.pressKey('a'); + utils.pressKey('a'); expect(a).toBe(1); expect(b).toBe(2); diff --git a/tests/jsPsych/timelines.test.js b/tests/jsPsych/timelines.test.js index fd5418d7..be29ad13 100644 --- a/tests/jsPsych/timelines.test.js +++ b/tests/jsPsych/timelines.test.js @@ -186,12 +186,12 @@ describe('loop function', function(){ }); // first trial - utils.pressKey(32); + utils.pressKey('a'); expect(count).toBe(0); // second trial - utils.pressKey(32); + utils.pressKey('a'); expect(count).toBe(1); }) @@ -321,12 +321,12 @@ describe('conditional function', function(){ expect(conditional_count).toBe(1); // first trial - utils.pressKey(32); + utils.pressKey('a'); expect(conditional_count).toBe(1); // second trial - utils.pressKey(32); + utils.pressKey('a'); expect(conditional_count).toBe(1); }) @@ -356,12 +356,12 @@ describe('conditional function', function(){ expect(conditional_count).toBe(1); // first trial - utils.pressKey(32); + utils.pressKey('a'); expect(conditional_count).toBe(1); // second trial - utils.pressKey(32); + utils.pressKey('a'); expect(conditional_count).toBe(1); })