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; 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(); +});