Fix lint and tests.

This commit is contained in:
Karishma Chadha 2018-05-21 13:51:43 -04:00
parent 1401d54add
commit 1639444a4d
6 changed files with 42 additions and 11 deletions

View file

@ -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');

View file

@ -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);

View file

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