mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Fix lint and tests.
This commit is contained in:
parent
1401d54add
commit
1639444a4d
6 changed files with 42 additions and 11 deletions
|
@ -735,6 +735,7 @@ class Blocks {
|
|||
/**
|
||||
* Encode all of `this._blocks` as an XML string usable
|
||||
* by a Blockly/scratch-blocks workspace.
|
||||
* @param {object<string, Comment>} comments Map of comments referenced by id
|
||||
* @return {string} String of XML representing this object's blocks.
|
||||
*/
|
||||
toXML (comments) {
|
||||
|
@ -745,6 +746,7 @@ class Blocks {
|
|||
* Recursively encode an individual block and its children
|
||||
* into a Blockly/scratch-blocks XML string.
|
||||
* @param {!string} blockId ID of block to encode.
|
||||
* @param {object<string, Comment>} comments Map of comments referenced by id
|
||||
* @return {string} String of XML representing this block and any children.
|
||||
*/
|
||||
blockToXML (blockId, comments) {
|
||||
|
|
|
@ -930,7 +930,6 @@ class RenderedTarget extends Target {
|
|||
newClone.rotationStyle = this.rotationStyle;
|
||||
newClone.effects = JSON.parse(JSON.stringify(this.effects));
|
||||
newClone.variables = JSON.parse(JSON.stringify(this.variables));
|
||||
newClone.lists = JSON.parse(JSON.stringify(this.lists));
|
||||
newClone.initDrawable(StageLayering.SPRITE_LAYER);
|
||||
newClone.updateAllDrawableProperties();
|
||||
// Place behind the current target.
|
||||
|
@ -957,7 +956,6 @@ class RenderedTarget extends Target {
|
|||
newTarget.rotationStyle = this.rotationStyle;
|
||||
newTarget.effects = JSON.parse(JSON.stringify(this.effects));
|
||||
newTarget.variables = JSON.parse(JSON.stringify(this.variables));
|
||||
newTarget.lists = JSON.parse(JSON.stringify(this.lists));
|
||||
newTarget.updateAllDrawableProperties();
|
||||
newTarget.goBehindOther(this);
|
||||
return newTarget;
|
||||
|
@ -1049,7 +1047,6 @@ class RenderedTarget extends Target {
|
|||
rotationStyle: this.rotationStyle,
|
||||
blocks: this.blocks._blocks,
|
||||
variables: this.variables,
|
||||
lists: this.lists,
|
||||
costumes: costumes,
|
||||
sounds: this.getSounds(),
|
||||
tempo: this.tempo,
|
||||
|
|
|
@ -30,7 +30,6 @@ test('default', t => {
|
|||
t.type(targets[0].id, 'string');
|
||||
t.type(targets[0].blocks, 'object');
|
||||
t.type(targets[0].variables, 'object');
|
||||
t.type(targets[0].lists, 'object');
|
||||
|
||||
t.equal(targets[0].isOriginal, true);
|
||||
t.equal(targets[0].currentCostume, 0);
|
||||
|
@ -41,7 +40,6 @@ test('default', t => {
|
|||
t.type(targets[1].id, 'string');
|
||||
t.type(targets[1].blocks, 'object');
|
||||
t.type(targets[1].variables, 'object');
|
||||
t.type(targets[1].lists, 'object');
|
||||
|
||||
t.equal(targets[1].isOriginal, true);
|
||||
t.equal(targets[1].currentCostume, 0);
|
||||
|
|
|
@ -12,7 +12,6 @@ test('spec', t => {
|
|||
t.type(target.id, 'string');
|
||||
t.type(target.blocks, 'object');
|
||||
t.type(target.variables, 'object');
|
||||
t.type(target.lists, 'object');
|
||||
t.type(target._customState, 'object');
|
||||
|
||||
t.type(target.createVariable, 'function');
|
||||
|
|
|
@ -29,7 +29,6 @@ test('default', t => {
|
|||
t.type(targets[0].id, 'string');
|
||||
t.type(targets[0].blocks, 'object');
|
||||
t.type(targets[0].variables, 'object');
|
||||
t.type(targets[0].lists, 'object');
|
||||
|
||||
t.equal(targets[0].isOriginal, true);
|
||||
t.equal(targets[0].currentCostume, 0);
|
||||
|
@ -40,7 +39,6 @@ test('default', t => {
|
|||
t.type(targets[1].id, 'string');
|
||||
t.type(targets[1].blocks, 'object');
|
||||
t.type(targets[1].variables, 'object');
|
||||
t.type(targets[1].lists, 'object');
|
||||
|
||||
t.equal(targets[1].isOriginal, true);
|
||||
t.equal(targets[1].currentCostume, 0);
|
||||
|
|
|
@ -307,6 +307,17 @@ test('duplicateSprite assigns duplicated sprite a fresh name', t => {
|
|||
|
||||
test('emitWorkspaceUpdate', t => {
|
||||
const vm = new VirtualMachine();
|
||||
const blocksToXML = comments => {
|
||||
let blockString = 'blocks\n';
|
||||
if (comments) {
|
||||
for (const commentId in comments) {
|
||||
const comment = comments[commentId];
|
||||
blockString += `A Block Comment: ${comment.toXML()}`;
|
||||
}
|
||||
|
||||
}
|
||||
return blockString;
|
||||
};
|
||||
vm.runtime.targets = [
|
||||
{
|
||||
isStage: true,
|
||||
|
@ -316,7 +327,13 @@ test('emitWorkspaceUpdate', t => {
|
|||
}
|
||||
},
|
||||
blocks: {
|
||||
toXML: () => 'blocks'
|
||||
toXML: blocksToXML
|
||||
},
|
||||
comments: {
|
||||
aStageComment: {
|
||||
toXML: () => 'aStageComment',
|
||||
blockId: null
|
||||
}
|
||||
}
|
||||
}, {
|
||||
variables: {
|
||||
|
@ -325,7 +342,13 @@ test('emitWorkspaceUpdate', t => {
|
|||
}
|
||||
},
|
||||
blocks: {
|
||||
toXML: () => 'blocks'
|
||||
toXML: blocksToXML
|
||||
},
|
||||
comments: {
|
||||
someBlockComment: {
|
||||
toXML: () => 'someBlockComment',
|
||||
blockId: 'someBlockId'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
variables: {
|
||||
|
@ -334,7 +357,17 @@ test('emitWorkspaceUpdate', t => {
|
|||
}
|
||||
},
|
||||
blocks: {
|
||||
toXML: () => 'blocks'
|
||||
toXML: blocksToXML
|
||||
},
|
||||
comments: {
|
||||
someOtherComment: {
|
||||
toXML: () => 'someOtherComment',
|
||||
blockId: null
|
||||
},
|
||||
aBlockComment: {
|
||||
toXML: () => 'aBlockComment',
|
||||
blockId: 'a block'
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -347,6 +380,10 @@ test('emitWorkspaceUpdate', t => {
|
|||
t.notEqual(xml.indexOf('local'), -1);
|
||||
t.equal(xml.indexOf('unused'), -1);
|
||||
t.notEqual(xml.indexOf('blocks'), -1);
|
||||
t.equal(xml.indexOf('aStageComment'), -1);
|
||||
t.equal(xml.indexOf('someBlockComment'), -1);
|
||||
t.notEqual(xml.indexOf('someOtherComment'), -1);
|
||||
t.notEqual(xml.indexOf('A Block Comment: aBlockComment'), -1);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue