Fix tests: don't require('scratch-blocks')

This commit is contained in:
Christopher Willis-Ford 2017-09-06 01:24:24 -06:00
parent 799d61ac98
commit 635c7966eb

View file

@ -1,8 +1,6 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const {OrderedMap} = require('immutable'); const {OrderedMap} = require('immutable');
const ScratchBlocks = require('scratch-blocks');
const ArgumentType = require('../extension-support/argument-type'); const ArgumentType = require('../extension-support/argument-type');
const Blocks = require('./blocks'); const Blocks = require('./blocks');
const BlockType = require('../extension-support/block-type'); const BlockType = require('../extension-support/block-type');
@ -50,6 +48,32 @@ const ArgumentTypeMap = (() => {
return map; return map;
})(); })();
/**
* These constants are copied from scratch-blocks/core/constants.js
* @TODO find a way to require() these... maybe make a scratch-blocks/dist/constants.js or something like that?
* @readonly
* @enum {int}
*/
const ScratchBlocksConstants = {
/**
* ENUM for output shape: hexagonal (booleans/predicates).
* @const
*/
OUTPUT_SHAPE_HEXAGONAL: 1,
/**
* ENUM for output shape: rounded (numbers).
* @const
*/
OUTPUT_SHAPE_ROUND: 2,
/**
* ENUM for output shape: squared (any/all values; strings).
* @const
*/
OUTPUT_SHAPE_SQUARE: 3
};
/** /**
* Manages targets, scripts, and the sequencer. * Manages targets, scripts, and the sequencer.
* @constructor * @constructor
@ -445,7 +469,7 @@ class Runtime extends EventEmitter {
switch (blockInfo.blockType) { switch (blockInfo.blockType) {
case BlockType.COMMAND: case BlockType.COMMAND:
blockJSON.outputShape = ScratchBlocks.OUTPUT_SHAPE_SQUARE; blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE;
blockJSON.previousStatement = null; // null = available connection; undefined = hat blockJSON.previousStatement = null; // null = available connection; undefined = hat
if (!blockInfo.isTerminal) { if (!blockInfo.isTerminal) {
blockJSON.nextStatement = null; // null = available connection; undefined = terminal blockJSON.nextStatement = null; // null = available connection; undefined = terminal
@ -453,14 +477,14 @@ class Runtime extends EventEmitter {
break; break;
case BlockType.REPORTER: case BlockType.REPORTER:
blockJSON.output = 'String'; // TODO: distinguish number & string here? blockJSON.output = 'String'; // TODO: distinguish number & string here?
blockJSON.outputShape = ScratchBlocks.OUTPUT_SHAPE_ROUND; blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_ROUND;
break; break;
case BlockType.BOOLEAN: case BlockType.BOOLEAN:
blockJSON.output = 'Boolean'; blockJSON.output = 'Boolean';
blockJSON.outputShape = ScratchBlocks.OUTPUT_SHAPE_HEXAGONAL; blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_HEXAGONAL;
break; break;
case BlockType.HAT: case BlockType.HAT:
blockJSON.outputShape = ScratchBlocks.OUTPUT_SHAPE_SQUARE; blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE;
blockJSON.nextStatement = null; // null = available connection; undefined = terminal blockJSON.nextStatement = null; // null = available connection; undefined = terminal
break; break;
case BlockType.CONDITIONAL: case BlockType.CONDITIONAL:
@ -472,7 +496,7 @@ class Runtime extends EventEmitter {
name: `SUBSTACK${branchNum > 1 ? branchNum : ''}` name: `SUBSTACK${branchNum > 1 ? branchNum : ''}`
}]; }];
} }
blockJSON.outputShape = ScratchBlocks.OUTPUT_SHAPE_SQUARE; blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE;
blockJSON.previousStatement = null; // null = available connection; undefined = hat blockJSON.previousStatement = null; // null = available connection; undefined = hat
blockJSON.nextStatement = null; // null = available connection; undefined = terminal blockJSON.nextStatement = null; // null = available connection; undefined = terminal
break; break;