mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-29 22:54:13 -04:00
test: don't use process.exit to end tests
Newer versions of `tap` run more asynchronously, so sometimes using `process.nextTick(process.exit)` to end a test would prevent the test from completing correctly. Removing all instances of `process.nextTick(process.exit)` put tests into three categories: * the test still worked correctly -- no fixup needed. * the test would hang because the VM's `_steppingInterval` was keeping Node alive. These tests call a new `quit()` method which ends the stepping interval. * the `load-extensions` test needed special attention because the "Video Sensing" extension starts its own loop using `setTimeout`. I added a `_stopLoop()` method on the extension and directly call that from the test. I'm not completely happy with this solution but anything more general would likely require a change to the extension spec, so I'm leaving that as a followup task.
This commit is contained in:
parent
605b1c2386
commit
840ffb5df0
69 changed files with 182 additions and 156 deletions
test
integration
addSprite.jsblock_to_workspace_comment_import.jsblock_to_workspace_comment_import_no_scripts.jsbroadcast_special_chars_sb2.jsbroadcast_special_chars_sb3.jsclone-cleanup.jscloud_variables_sb2.jscloud_variables_sb3.jscomments.jscomments_sb3.jscomplex.jscontrol.jsdata.jsdelete-and-restore-sprite.jsevent.jsexecute.jshat-execution-order.jsimport-sb.jsimport-sb2-from-object.jslist-monitor-rename.jsload-extensions.jsload-sb2-originally-sb1-without-backdrop-image.jslooks.jsmonitors_sb2.jsmonitors_sb2_to_sb3.jsmonitors_sb3.jsmotion.jsoffline-custom-assets.jspen.jsprocedure.jsrunning_project_changed_state.jssaythink-and-wait.jssb2-import-extension-monitors.jssb2_corrupted_png.jssb2_corrupted_svg.jssb2_missing_png.jssb2_missing_svg.jssb3_corrupted_png.jssb3_corrupted_sound.jssb3_corrupted_svg.jssb3_missing_png.jssb3_missing_sound.jssb3_missing_svg.jssensing.jssound.jssprite2_corrupted_png.jssprite2_corrupted_svg.jssprite2_missing_png.jssprite2_missing_svg.jssprite3_corrupted_png.jssprite3_corrupted_svg.jssprite3_missing_png.jssprite3_missing_svg.jsstack-click.jsunknown-opcode-as-reporter-block.jsunknown-opcode-in-c-block.jsunknown-opcode.jsvariable_monitor_reset.jsvariable_special_chars_sb2.jsvariable_special_chars_sb3.js
unit
|
@ -27,8 +27,8 @@ test('default cat', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
vm.start();
|
||||
|
|
|
@ -33,8 +33,8 @@ test('importing sb2 project where block comment is converted to workspace commen
|
|||
const invalidComments = targetComments.filter(comment => typeof comment.blockId === 'number');
|
||||
t.equal(invalidComments.length, 0);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -38,8 +38,8 @@ test('importing sb2 project where block comment is converted to workspace commen
|
|||
const targetBlocks = Object.values(target.blocks._blocks);
|
||||
t.equal(targetBlocks.length, 0);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -62,8 +62,8 @@ test('importing sb2 project with special chars in message names', t => {
|
|||
t.equal(catMessageBlocks[0].fields.BROADCAST_OPTION.id, ltPerfectMessageId);
|
||||
t.equal(catMessageBlocks[1].fields.BROADCAST_OPTION.id, abMessageId);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -62,8 +62,8 @@ test('importing sb3 project with special chars in message names', t => {
|
|||
t.equal(catMessageBlocks[0].fields.BROADCAST_OPTION.id, ltPerfectMessageId);
|
||||
t.equal(catMessageBlocks[1].fields.BROADCAST_OPTION.id, abMessageId);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -65,8 +65,8 @@ test('clone-cleanup', t => {
|
|||
// The second batch of clones has deleted themselves; everything is finished
|
||||
verifyCounts(0, 0);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,6 +37,7 @@ test('importing an sb2 project with cloud variables', t => {
|
|||
// when the message is being sent to the server rather than on the client
|
||||
t.equal(variable.isCloud, true);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -60,6 +61,7 @@ test('importing an sb2 project with cloud variables at the limit for a project',
|
|||
// All of the 8 stage variables should be cloud variables
|
||||
t.equal(stageVars.filter(v => v.isCloud).length, 10);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -85,6 +87,7 @@ test('importing an sb2 project with cloud variables exceeding the limit for a pr
|
|||
// Only 8 of the variables should have the isCloud flag set to true
|
||||
t.equal(stageVars.filter(v => v.isCloud).length, 10);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -115,6 +118,7 @@ test('importing one project after the other resets cloud variable limit', t => {
|
|||
|
||||
t.equal(vm.runtime.canAddCloudVariable(), true);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -145,8 +149,7 @@ test('local cloud variables get imported as regular variables', t => {
|
|||
t.equal(spriteVars.length, 1);
|
||||
t.equal(spriteVars[0].isCloud, false);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
|
||||
process.nextTick(process.exit); // This is needed because this is the end of the last test in this file!!!
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,6 +35,7 @@ test('importing an sb3 project with cloud variables', t => {
|
|||
t.equal(Number(variable.value), 100);
|
||||
t.equal(variable.isCloud, true);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -58,6 +59,7 @@ test('importing an sb3 project with cloud variables at the limit for a project',
|
|||
// All of the 10 stage variables should be cloud variables
|
||||
t.equal(stageVars.filter(v => v.isCloud).length, 10);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -83,6 +85,7 @@ test('importing an sb3 project with cloud variables exceeding the limit for a pr
|
|||
// Only 8 of the variables should have the isCloud flag set to true
|
||||
t.equal(stageVars.filter(v => v.isCloud).length, 10);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -111,6 +114,7 @@ test('importing one project after the other resets cloud variable limit', t => {
|
|||
|
||||
t.equal(vm.runtime.canAddCloudVariable(), true);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -141,8 +145,7 @@ test('local cloud variables get imported as regular variables', t => {
|
|||
t.equal(spriteVars.length, 1);
|
||||
t.equal(spriteVars[0].isCloud, false);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
|
||||
process.nextTick(process.exit); // This is needed because this is the end of the last test in this file!!!
|
||||
});
|
||||
});
|
||||
|
|
|
@ -70,8 +70,8 @@ test('importing sb2 project with comments', t => {
|
|||
t.equal(stopAllBlock.comment, blockComments[4].id);
|
||||
t.equal(stopAllBlock.opcode, 'control_stop');
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -70,8 +70,8 @@ test('load an sb3 project with comments', t => {
|
|||
t.equal(stopAllBlock.comment, blockComments[4].id);
|
||||
t.equal(stopAllBlock.opcode, 'control_stop');
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -19,8 +19,8 @@ test('complex', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Manipulate each target
|
||||
|
|
|
@ -15,8 +15,8 @@ test('control', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length > 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -14,8 +14,8 @@ test('data', t => {
|
|||
// Evaluate playground data and exit
|
||||
vm.on('playgroundData', () => {
|
||||
// @todo Additional tests
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -27,8 +27,8 @@ test('default cat', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
vm.start();
|
||||
|
|
|
@ -15,8 +15,8 @@ test('event', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length > 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -66,6 +66,8 @@ fs.readdirSync(executeDir)
|
|||
log.suggest.deny('vm', 'error');
|
||||
t.tearDown(() => log.suggest.clear());
|
||||
|
||||
const vm = new VirtualMachine();
|
||||
|
||||
// Map string messages to tap reporting methods. This will be used
|
||||
// with events from scratch's runtime emitted on block instructions.
|
||||
let didPlan;
|
||||
|
@ -86,6 +88,7 @@ fs.readdirSync(executeDir)
|
|||
},
|
||||
end () {
|
||||
didEnd = true;
|
||||
vm.quit();
|
||||
t.end();
|
||||
}
|
||||
};
|
||||
|
@ -100,7 +103,6 @@ fs.readdirSync(executeDir)
|
|||
return reporters.comment(text);
|
||||
};
|
||||
|
||||
const vm = new VirtualMachine();
|
||||
vm.attachStorage(makeTestStorage());
|
||||
|
||||
// Start the VM and initialize some vm properties.
|
||||
|
@ -138,6 +140,7 @@ fs.readdirSync(executeDir)
|
|||
// it can be resolved.
|
||||
if (!didEnd) {
|
||||
t.fail('did not say "end"');
|
||||
vm.quit();
|
||||
t.end();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,8 +20,8 @@ test('complex', t => {
|
|||
const results = vm.runtime.targets[0].variables[resultKey].value;
|
||||
t.deepEqual(results, ['3', '2', '1', 'stage']);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -15,8 +15,8 @@ test('default', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -15,8 +15,8 @@ test('default', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -31,8 +31,8 @@ test('importing sb3 project with incorrect list monitor name', t => {
|
|||
t.equal(monitorBlock.fields.LIST.value, renamedListName);
|
||||
}
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -3,9 +3,19 @@ const tap = require('tap');
|
|||
const {test} = tap;
|
||||
const fs = require('fs');
|
||||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
||||
const dispatch = require('../../src/dispatch/central-dispatch');
|
||||
const VirtualMachine = require('../../src/index');
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
/**
|
||||
* Call _stopLoop() on the Video Sensing extension.
|
||||
* @param {VirtualMachine} vm - a VM instance which has loaded the 'videoSensing' extension.
|
||||
*/
|
||||
const stopVideoLoop = vm => {
|
||||
// TODO: provide a general way to tell extensions to shut down
|
||||
// Ideally we'd just dispose of the extension's Worker...
|
||||
const serviceName = vm.extensionManager._loadedExtensions.get('videoSensing');
|
||||
dispatch.call(serviceName, '_stopLoop');
|
||||
};
|
||||
|
||||
test('Load external extensions', async t => {
|
||||
const vm = new VirtualMachine();
|
||||
|
@ -25,6 +35,9 @@ test('Load external extensions', async t => {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
stopVideoLoop(vm);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
@ -64,5 +77,7 @@ test('Load video sensing extension and video properties', async t => {
|
|||
t.equal(vm.runtime.ioDevices.video._ghost, project.videoTransparency);
|
||||
}
|
||||
|
||||
stopVideoLoop(vm);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
|
|
|
@ -17,8 +17,8 @@ test('sb2 project (originally from Scratch 1.4) with missing backdrop image shou
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
vm.start();
|
||||
|
|
|
@ -15,8 +15,8 @@ test('looks', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -122,8 +122,8 @@ test('importing sb2 project with monitors', t => {
|
|||
t.equal(monitorRecord.spriteName, null);
|
||||
t.equal(monitorRecord.targetId, null);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -140,7 +140,6 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide
|
|||
t.equal(monitorRecord.targetId, null);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -247,8 +247,8 @@ test('importing sb3 project with monitors', t => {
|
|||
t.equal(monitorRecord.targetId, null);
|
||||
t.equal(vm.extensionManager.isExtensionLoaded('ev3'), true);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -15,8 +15,8 @@ test('motion', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length > 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -33,8 +33,8 @@ test('offline-custom-assets', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -37,8 +37,8 @@ test('pen', t => {
|
|||
t.equal(originalPenState.penAttributes.diameter, 51);
|
||||
t.equal(clonePenState.penAttributes.diameter, 42);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -15,8 +15,8 @@ test('procedure', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length === 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -19,8 +19,8 @@ test('Running project should not emit project changed event', t => {
|
|||
// Evaluate playground data and exit
|
||||
vm.on('playgroundData', () => {
|
||||
t.equal(projectChanged, false);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -29,8 +29,8 @@ test('say/think and wait', t => {
|
|||
// The test will fail if the project throws.
|
||||
setTimeout(() => {
|
||||
vm.stopAll();
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,8 +25,6 @@ const visibleTempoMonitorProjectUri = path.resolve(
|
|||
__dirname, '../fixtures/visible-tempo-monitor-no-other-music-blocks.sb2');
|
||||
const visibleTempoMonitorProject = readFileToBuffer(visibleTempoMonitorProjectUri);
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
test('loading sb2 project with invisible video monitor should not load monitor or extension', t => {
|
||||
const vm = new VirtualMachine();
|
||||
vm.attachStorage(makeTestStorage());
|
||||
|
@ -39,6 +37,7 @@ test('loading sb2 project with invisible video monitor should not load monitor o
|
|||
vm.loadProject(invisibleVideoMonitorProject).then(() => {
|
||||
t.equal(vm.extensionManager.isExtensionLoaded('videoSensing'), false);
|
||||
t.equal(vm.runtime._monitorState.size, 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -55,6 +54,7 @@ test('loading sb2 project with visible video monitor should not load extension',
|
|||
vm.loadProject(visibleVideoMonitorProject).then(() => {
|
||||
t.equal(vm.extensionManager.isExtensionLoaded('videoSensing'), false);
|
||||
t.equal(vm.runtime._monitorState.size, 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -86,6 +86,7 @@ test('sb2 project with invisible music monitor should not load monitor or extens
|
|||
vm.loadProject(invisibleTempoMonitorProject).then(() => {
|
||||
t.equal(vm.extensionManager.isExtensionLoaded('music'), false);
|
||||
t.equal(vm.runtime._monitorState.size, 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
@ -104,6 +105,7 @@ test('sb2 project with visible music monitor should load monitor and extension',
|
|||
t.equal(vm.runtime._monitorState.size, 1);
|
||||
t.equal(vm.runtime._monitorState.has('music_getTempo'), true);
|
||||
t.equal(vm.runtime._monitorState.get('music_getTempo').visible, true);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -71,14 +71,14 @@ const test = tap.test;
|
|||
|
||||
test('load sb2 project with corrupted bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[1];
|
||||
t.equal(greenGuySprite.getName(), 'GreenGuy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'GreenGuy');
|
||||
t.equal(corruptedCostume.assetId, defaultBitmapAssetId);
|
||||
|
@ -96,14 +96,14 @@ test('load and then save project with corrupted bitmap costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = resavedProject.targets[1];
|
||||
t.equal(greenGuySprite.name, 'GreenGuy');
|
||||
t.equal(greenGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'GreenGuy');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@ global.Image = function () {
|
|||
width: 1,
|
||||
height: 1
|
||||
};
|
||||
|
||||
|
||||
setTimeout(() => image.onload(), 1000);
|
||||
return image;
|
||||
};
|
||||
|
@ -73,14 +73,14 @@ const test = tap.test;
|
|||
|
||||
test('load sb2 project with corrupted vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[1];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'Blue Guy 2');
|
||||
t.equal(corruptedCostume.assetId, defaultVectorAssetId);
|
||||
|
@ -98,14 +98,14 @@ test('load and then save project with corrupted vector costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = resavedProject.targets[1];
|
||||
t.equal(blueGuySprite.name, 'Blue Guy');
|
||||
t.equal(blueGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'Blue Guy 2');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -124,5 +124,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -56,14 +56,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sb2 project with missing bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[1];
|
||||
t.equal(greenGuySprite.getName(), 'GreenGuy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'GreenGuy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -81,14 +81,14 @@ test('load and then save sb2 project with missing costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = resavedProject.targets[1];
|
||||
t.equal(greenGuySprite.name, 'GreenGuy');
|
||||
t.equal(greenGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'GreenGuy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -102,10 +102,9 @@ test('load and then save sb2 project with missing costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 1); // Should only have one costume, the backdrop
|
||||
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.png`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -55,14 +55,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sb2 project with missing vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[1];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'Blue Guy 2');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -80,14 +80,14 @@ test('load and then save sb2 project with missing costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = resavedProject.targets[1];
|
||||
t.equal(blueGuySprite.name, 'Blue Guy');
|
||||
t.equal(blueGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'Blue Guy 2');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -101,10 +101,9 @@ test('load and then save sb2 project with missing costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 1); // Should only have one costume, the backdrop
|
||||
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.svg`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -71,14 +71,14 @@ const test = tap.test;
|
|||
|
||||
test('load sb3 project with corrupted bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[1];
|
||||
t.equal(greenGuySprite.getName(), 'Green Guy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'Green Guy');
|
||||
t.equal(corruptedCostume.assetId, defaultBitmapAssetId);
|
||||
|
@ -96,14 +96,14 @@ test('load and then save project with corrupted bitmap costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = resavedProject.targets[1];
|
||||
t.equal(greenGuySprite.name, 'Green Guy');
|
||||
t.equal(greenGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'Green Guy');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ const FakeAudioEngine = function () {
|
|||
if (soundDataString.includes('here is some')) {
|
||||
return Promise.reject(new Error('mock audio engine broke'));
|
||||
}
|
||||
|
||||
|
||||
// Otherwise return fake data
|
||||
return Promise.resolve({
|
||||
id: fakeId++,
|
||||
|
@ -65,14 +65,14 @@ const test = tap.test;
|
|||
|
||||
test('load sb3 project with corrupted sound file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const catSprite = vm.runtime.targets[1];
|
||||
t.equal(catSprite.getName(), 'Sprite1');
|
||||
t.equal(catSprite.getSounds().length, 1);
|
||||
|
||||
|
||||
const corruptedSound = catSprite.getSounds()[0];
|
||||
t.equal(corruptedSound.name, 'Boop Sound Recording');
|
||||
t.equal(corruptedSound.assetId, defaultSoundAssetId);
|
||||
|
@ -90,14 +90,14 @@ test('load and then save project with corrupted sound file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const catSprite = resavedProject.targets[1];
|
||||
t.equal(catSprite.name, 'Sprite1');
|
||||
t.equal(catSprite.sounds.length, 1);
|
||||
|
||||
|
||||
const corruptedSound = catSprite.sounds[0];
|
||||
t.equal(corruptedSound.name, 'Boop Sound Recording');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -116,5 +116,4 @@ test('serializeSounds saves orignal broken sound', t => {
|
|||
t.equal(sound.fileName, `${brokenSoundMd5}.wav`);
|
||||
t.equal(md5(sound.fileContent), brokenSoundMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -52,14 +52,14 @@ const test = tap.test;
|
|||
|
||||
test('load sb3 project with corrupted vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[1];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'costume1');
|
||||
t.equal(corruptedCostume.assetId, defaultVectorAssetId);
|
||||
|
@ -77,14 +77,14 @@ test('load and then save project with corrupted vector costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = resavedProject.targets[1];
|
||||
t.equal(blueGuySprite.name, 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'costume1');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -103,5 +103,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -56,14 +56,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sb3 project with missing bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[1];
|
||||
t.equal(greenGuySprite.getName(), 'Green Guy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'Green Guy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -81,14 +81,14 @@ test('load and then save sb3 project with missing costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = resavedProject.targets[1];
|
||||
t.equal(greenGuySprite.name, 'Green Guy');
|
||||
t.equal(greenGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'Green Guy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -102,10 +102,9 @@ test('load and then save sb3 project with missing costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 1); // Should only have one costume, the backdrop
|
||||
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.png`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -32,13 +32,13 @@ const test = tap.test;
|
|||
|
||||
test('loading sb3 project with missing sound file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const catSprite = vm.runtime.targets[1];
|
||||
t.equal(catSprite.getSounds().length, 1);
|
||||
|
||||
|
||||
const missingSound = catSprite.getSounds()[0];
|
||||
t.equal(missingSound.name, 'Boop Sound Recording');
|
||||
// Sound should have original data but no asset
|
||||
|
@ -57,14 +57,14 @@ test('load and then save sb3 project with missing sound file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const catSprite = resavedProject.targets[1];
|
||||
t.equal(catSprite.name, 'Sprite1');
|
||||
t.equal(catSprite.sounds.length, 1);
|
||||
|
||||
|
||||
const missingSound = catSprite.sounds[0];
|
||||
t.equal(missingSound.name, 'Boop Sound Recording');
|
||||
// Costume should have both default sound data (e.g. "Gray Question Sound" ^_^) and original data
|
||||
|
@ -78,10 +78,9 @@ test('load and then save sb3 project with missing sound file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const soundDescs = serializeSounds(vm.runtime);
|
||||
|
||||
|
||||
t.equal(soundDescs.length, 1); // Should only have one sound, the pop sound for the stage
|
||||
t.not(soundDescs[0].fileName, `${missingSoundAssetId}.wav`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -35,14 +35,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sb3 project with missing vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 2);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[1];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'costume1');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -60,14 +60,14 @@ test('load and then save sb3 project with missing costume file', t => {
|
|||
const resavedProject = JSON.parse(vm.toJSON());
|
||||
|
||||
t.equal(resavedProject.targets.length, 2);
|
||||
|
||||
|
||||
const stage = resavedProject.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = resavedProject.targets[1];
|
||||
t.equal(blueGuySprite.name, 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'costume1');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -81,10 +81,9 @@ test('load and then save sb3 project with missing costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 1); // Should only have one costume, the backdrop
|
||||
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.svg`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -15,8 +15,8 @@ test('sensing', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length > 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -20,8 +20,8 @@ test('sound', t => {
|
|||
vm.on('playgroundData', e => {
|
||||
const threads = JSON.parse(e.threads);
|
||||
t.ok(threads.length > 0);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -76,14 +76,14 @@ const test = tap.test;
|
|||
|
||||
test('load sprite2 with corrupted bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[2];
|
||||
t.equal(greenGuySprite.getName(), 'GreenGuy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'GreenGuy');
|
||||
t.equal(corruptedCostume.assetId, defaultBitmapAssetId);
|
||||
|
@ -102,7 +102,7 @@ test('load and then save sprite with corrupted costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'GreenGuy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = resavedSprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'GreenGuy');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -121,5 +121,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -77,14 +77,14 @@ const test = tap.test;
|
|||
|
||||
test('load sprite2 with corrupted vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[2];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'Blue Guy 2');
|
||||
t.equal(corruptedCostume.assetId, defaultVectorAssetId);
|
||||
|
@ -103,7 +103,7 @@ test('load and then save sprite with corrupted costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Blue Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = resavedSprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'Blue Guy 2');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -59,14 +59,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sprite2 with missing bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[2];
|
||||
t.equal(greenGuySprite.getName(), 'GreenGuy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'GreenGuy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -85,7 +85,7 @@ test('load and then save sprite2 with missing bitmap costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'GreenGuy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = resavedSprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'GreenGuy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -99,9 +99,8 @@ test('load and then save sprite2 with missing bitmap costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime, vm.runtime.targets[2].id);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 0);
|
||||
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -59,14 +59,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sprite2 with missing vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[2];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'Blue Guy 2');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -85,7 +85,7 @@ test('load and then save sprite2 with missing vector costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Blue Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = resavedSprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'Blue Guy 2');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -99,9 +99,8 @@ test('load and then save sprite2 with missing vector costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime, vm.runtime.targets[2].id);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 0);
|
||||
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -76,14 +76,14 @@ const test = tap.test;
|
|||
|
||||
test('load sprite3 with corrupted bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[2];
|
||||
t.equal(greenGuySprite.getName(), 'Green Guy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'Green Guy');
|
||||
t.equal(corruptedCostume.assetId, defaultBitmapAssetId);
|
||||
|
@ -102,7 +102,7 @@ test('load and then save sprite with corrupted costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Green Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = resavedSprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'Green Guy');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -121,5 +121,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -57,14 +57,14 @@ const test = tap.test;
|
|||
|
||||
test('load sprite3 with corrupted vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[2];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(corruptedCostume.name, 'costume1');
|
||||
t.equal(corruptedCostume.assetId, defaultVectorAssetId);
|
||||
|
@ -83,7 +83,7 @@ test('load and then save sprite with corrupted costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Blue Square Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const corruptedCostume = resavedSprite.costumes[0];
|
||||
t.equal(corruptedCostume.name, 'costume1');
|
||||
// Resaved project costume should have the metadata that corresponds to the original broken costume
|
||||
|
@ -102,5 +102,4 @@ test('serializeCostume saves orignal broken costume', t => {
|
|||
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
|
||||
t.equal(md5(costume.fileContent), brokenCostumeMd5);
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -59,14 +59,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sprite3 with missing bitmap costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const greenGuySprite = vm.runtime.targets[2];
|
||||
t.equal(greenGuySprite.getName(), 'Green Guy');
|
||||
t.equal(greenGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = greenGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'Green Guy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -85,7 +85,7 @@ test('load and then save sprite3 with missing bitmap costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Green Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = resavedSprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'Green Guy');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -99,9 +99,8 @@ test('load and then save sprite3 with missing bitmap costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime, vm.runtime.targets[2].id);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 0);
|
||||
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -39,14 +39,14 @@ const test = tap.test;
|
|||
|
||||
test('loading sprite3 with missing vector costume file', t => {
|
||||
t.equal(vm.runtime.targets.length, 3);
|
||||
|
||||
|
||||
const stage = vm.runtime.targets[0];
|
||||
t.ok(stage.isStage);
|
||||
|
||||
const blueGuySprite = vm.runtime.targets[2];
|
||||
t.equal(blueGuySprite.getName(), 'Blue Square Guy');
|
||||
t.equal(blueGuySprite.getCostumes().length, 1);
|
||||
|
||||
|
||||
const missingCostume = blueGuySprite.getCostumes()[0];
|
||||
t.equal(missingCostume.name, 'costume1');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -65,7 +65,7 @@ test('load and then save sprite3 with missing vector costume file', t => {
|
|||
|
||||
t.equal(resavedSprite.name, 'Blue Square Guy');
|
||||
t.equal(resavedSprite.costumes.length, 1);
|
||||
|
||||
|
||||
const missingCostume = resavedSprite.costumes[0];
|
||||
t.equal(missingCostume.name, 'costume1');
|
||||
// Costume should have both default cosutme (e.g. Gray Question Mark) data and original data
|
||||
|
@ -79,9 +79,8 @@ test('load and then save sprite3 with missing vector costume file', t => {
|
|||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime, vm.runtime.targets[2].id);
|
||||
|
||||
|
||||
t.equal(costumeDescs.length, 0);
|
||||
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -22,8 +22,8 @@ test('stack click activates the stack', t => {
|
|||
vm.on('playgroundData', () => {
|
||||
// The sprite should have moved 100 to the right
|
||||
t.equal(vm.editingTarget.x, 100);
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -48,7 +48,7 @@ test('unknown opcode', t => {
|
|||
t.true(blocks.getBlock(fourthBlockInputId).shadow);
|
||||
t.equal(blocks.getBlock(fourthBlockInputId).opcode, 'sound_sounds_menu');
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ test('unknown opcode', t => {
|
|||
t.equal(blocks.getBlock(secondBlockId).opcode, 'control_forever');
|
||||
t.equal(innerBlockId, null);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ test('unknown opcode', t => {
|
|||
t.equal(undefinedComment.x, 0);
|
||||
t.equal(undefinedComment.y, 0);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,8 +35,8 @@ test('importing one project after the other resets monitored variables', t => {
|
|||
const jamalVarBlock = vm.runtime.monitorBlocks.getBlock(jamalVarId);
|
||||
t.notOk(jamalVarBlock);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -114,8 +114,8 @@ test('importing sb2 project with special chars in variable names', t => {
|
|||
t.equal(bananasVarBlocks.length, 1);
|
||||
t.equal(bananasVarBlocks[0].fields.VARIABLE.id, ltPerfectVarId);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -114,8 +114,8 @@ test('importing sb3 project with special chars in variable names', t => {
|
|||
t.equal(bananasVarBlocks.length, 1);
|
||||
t.equal(bananasVarBlocks[0].fields.VARIABLE.id, ltPerfectVarId);
|
||||
|
||||
vm.quit();
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
||||
// Start VM, load project, and run
|
||||
|
|
|
@ -6,8 +6,6 @@ const Runtime = require('../../src/engine/runtime');
|
|||
const MonitorRecord = require('../../src/engine/monitor-record');
|
||||
const {Map} = require('immutable');
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
test('spec', t => {
|
||||
|
@ -193,6 +191,7 @@ test('Starting the runtime emits an event', t => {
|
|||
});
|
||||
rt.start();
|
||||
t.equal(started, true);
|
||||
rt.quit();
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
@ -209,6 +208,7 @@ test('Runtime cannot be started while already running', t => {
|
|||
// Starting again should not emit another event
|
||||
rt.start();
|
||||
t.equal(started, false);
|
||||
rt.quit();
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
@ -224,6 +224,7 @@ test('setCompatibilityMode restarts if it was already running', t => {
|
|||
|
||||
rt.setCompatibilityMode(true);
|
||||
t.equal(started, true);
|
||||
rt.quit();
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ tap.beforeEach(() => {
|
|||
});
|
||||
});
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
test('Adding a sprite (from sprite2) should emit a project changed event', t => {
|
||||
|
|
|
@ -53,8 +53,6 @@ tap.beforeEach(() => {
|
|||
});
|
||||
});
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
test('Creating a block should emit a project changed event', t => {
|
||||
|
|
|
@ -4,8 +4,6 @@ const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer
|
|||
const makeTestStorage = require('../fixtures/make-test-storage');
|
||||
const VirtualMachine = require('../../src/virtual-machine');
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
// Test that loading a project does not emit a project change
|
||||
|
|
|
@ -8,8 +8,6 @@ const Renderer = require('../fixtures/fake-renderer');
|
|||
const Runtime = require('../../src/engine/runtime');
|
||||
const RenderedTarget = require('../../src/sprites/rendered-target');
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
test('deleteSound returns function after deleting or null if nothing was deleted', t => {
|
||||
|
@ -1016,6 +1014,7 @@ test('Starting the VM emits an event', t => {
|
|||
});
|
||||
vm.start();
|
||||
t.equal(started, true);
|
||||
vm.quit();
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue