add passing unit test

This commit is contained in:
Luke Schlangen 2018-02-07 17:49:18 -06:00
parent f8dced53dc
commit 45cf1f685d
2 changed files with 16 additions and 7 deletions

View file

@ -255,7 +255,8 @@ class Scratch3LooksBlocks {
if (typeof message === 'number') { if (typeof message === 'number') {
message = message.toFixed(2); message = message.toFixed(2);
} }
this._updateBubble(util.target, 'say', String(args.MESSAGE)); message = String(message);
this.runtime.emit('SAY', util.target, 'say', message);
} }
sayforsecs (args, util) { sayforsecs (args, util) {

View file

@ -1,5 +1,6 @@
const test = require('tap').test; const test = require('tap').test;
const Looks = require('../../src/blocks/scratch3_looks'); const Looks = require('../../src/blocks/scratch3_looks');
const Runtime = require('../../src/engine/runtime');
const util = { const util = {
target: { target: {
currentCostume: 0, // Internally, current costume is 0 indexed currentCostume: 0, // Internally, current costume is 0 indexed
@ -52,11 +53,18 @@ test('getBackdropNumberName can return costume name', t => {
}); });
test('numbers should be rounded to two decimals in say', t => { test('numbers should be rounded to two decimals in say', t => {
const rt = new Runtime();
const looks = new Looks(rt);
const args = {MESSAGE: 3.14159}; const args = {MESSAGE: 3.14159};
const sayString = blocks.say(args, util); const expectedSayString = '3.14';
// This breaks becuase it is not returned,
// instead this calls this._updateBubble(util.target, 'say', String(args.MESSAGE)); rt.removeAllListeners('SAY'); // Prevent say blocks from executing
// I'm not familiar
t.strictEqual(sayString, '3.14'); rt.addListener('SAY', (target, type, sayString) => {
t.end(); t.strictEqual(sayString, expectedSayString);
t.end();
});
looks.say(args, util);
}); });