mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
cd1c72c7cc
Rather than assuming that the storage instance will be attached to a VM, just return it. Callers may attach it to a `VM` or (in the case of `import_sb2.js`) to a `Runtime`.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
const path = require('path');
|
|
const test = require('tap').test;
|
|
const makeTestStorage = require('../fixtures/make-test-storage');
|
|
const extract = require('../fixtures/extract');
|
|
const VirtualMachine = require('../../src/index');
|
|
|
|
const uri = path.resolve(__dirname, '../fixtures/sound.sb2');
|
|
const project = extract(uri);
|
|
|
|
test('sound', t => {
|
|
const vm = new VirtualMachine();
|
|
vm.attachStorage(makeTestStorage());
|
|
|
|
// Evaluate playground data and exit
|
|
vm.on('playgroundData', e => {
|
|
const threads = JSON.parse(e.threads);
|
|
t.ok(threads.length > 0);
|
|
t.end();
|
|
process.nextTick(process.exit);
|
|
});
|
|
|
|
// Start VM, load project, and run
|
|
t.doesNotThrow(() => {
|
|
vm.start();
|
|
vm.clear();
|
|
vm.setCompatibilityMode(false);
|
|
vm.setTurboMode(false);
|
|
vm.loadProject(project).then(() => {
|
|
vm.greenFlag();
|
|
|
|
// After two seconds, get playground data and stop
|
|
setTimeout(() => {
|
|
vm.getPlaygroundData();
|
|
vm.stopAll();
|
|
}, 2000);
|
|
});
|
|
});
|
|
});
|