From c5cc1298216a06901287c85ee06bffc27c82b3b3 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 23 May 2018 11:30:12 -0400 Subject: [PATCH 1/2] Add logged out version of username block --- src/blocks/scratch3_sensing.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js index b19e4a368..f140997cf 100644 --- a/src/blocks/scratch3_sensing.js +++ b/src/blocks/scratch3_sensing.js @@ -68,6 +68,7 @@ class Scratch3SensingBlocks { sensing_loud: this.isLoud, sensing_askandwait: this.askAndWait, sensing_answer: this.getAnswer, + sensing_username: this.getUsername, sensing_userid: () => {} // legacy no-op block }; } @@ -315,6 +316,11 @@ class Scratch3SensingBlocks { // Otherwise, 0 return 0; } + + getUsername () { + // Logged out users get empty string. Return that for now. + return ''; + } } module.exports = Scratch3SensingBlocks; From 91e97ebdda15305da6ee2ad6e281147fa88e5d2a Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 23 May 2018 11:33:33 -0400 Subject: [PATCH 2/2] Gotta get that unit test coverage up :) --- test/unit/blocks_sensing.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/blocks_sensing.js b/test/unit/blocks_sensing.js index e791d38d5..cf607d3b9 100644 --- a/test/unit/blocks_sensing.js +++ b/test/unit/blocks_sensing.js @@ -143,3 +143,11 @@ test('loud? boolean', t => { t.end(); }); + +test('username block', t => { + const rt = new Runtime(); + const sensing = new Sensing(rt); + + t.equal(sensing.getUsername(), ''); + t.end(); +});