Fix pen tests

This commit is contained in:
Christopher Willis-Ford 2017-10-04 15:40:25 -07:00
parent dd20e09774
commit b6727a766f
4 changed files with 47 additions and 20 deletions
test/integration

View file

@ -1,8 +1,10 @@
const Worker = require('tiny-worker');
const path = require('path');
const test = require('tap').test;
const Scratch3PenBlocks = require('../../src/blocks/scratch3_pen');
const VirtualMachine = require('../../src/index');
const dispatch = require('../../src/dispatch/central-dispatch');
const makeTestStorage = require('../fixtures/make-test-storage');
const extract = require('../fixtures/extract');
@ -10,6 +12,9 @@ const extract = require('../fixtures/extract');
const uri = path.resolve(__dirname, '../fixtures/pen.sb2');
const project = extract(uri);
// By default Central Dispatch works with the Worker class built into the browser. Tell it to use TinyWorker instead.
dispatch.workerClass = Worker;
test('pen', t => {
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
@ -42,14 +47,16 @@ test('pen', t => {
vm.clear();
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
vm.loadProject(project).then(() => {
vm.greenFlag();
vm.loadProject(project)
.then(() => vm.extensionManager.loadExtensionURL('pen')) /** @TODO: loadProject should load extensions */
.then(() => {
vm.greenFlag();
// After two seconds, get playground data and stop
setTimeout(() => {
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});
// After two seconds, get playground data and stop
setTimeout(() => {
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});
});
});