Merge pull request #1866 from kchadha/update-sb1-converter

Update sb1-converter and add an sb import integration test.
This commit is contained in:
Karishma Chadha 2018-12-21 14:26:22 -05:00 committed by GitHub
commit 5ddc5dba4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 1 deletions

View file

@ -43,7 +43,7 @@
"minilog": "3.1.0", "minilog": "3.1.0",
"nets": "3.2.0", "nets": "3.2.0",
"scratch-parser": "4.3.3", "scratch-parser": "4.3.3",
"scratch-sb1-converter": "0.2.2", "scratch-sb1-converter": "0.2.4",
"scratch-translate-extension-languages": "0.0.20181205140428", "scratch-translate-extension-languages": "0.0.20181205140428",
"socket.io-client": "2.0.4", "socket.io-client": "2.0.4",
"text-encoding": "0.6.4", "text-encoding": "0.6.4",

BIN
test/fixtures/single_sound.sb vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,45 @@
const path = require('path');
const test = require('tap').test;
const makeTestStorage = require('../fixtures/make-test-storage');
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
const VirtualMachine = require('../../src/index');
const uri = path.resolve(__dirname, '../fixtures/single_sound.sb');
const project = readFileToBuffer(uri);
test('default', 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();
const stageSounds = vm.runtime.targets[0].sprite.sounds;
const firstSound = stageSounds[0];
// Check that the sound has the correct md5
// This md5 was obtained from the asset server
t.equal(firstSound.md5, 'edb9713dedbe9a2e05c09e0540182ef1.wav');
// After two seconds, get playground data and stop
setTimeout(() => {
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});
});
});