mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-10 06:52:00 -05:00
Pull JSON.parse into extractProjectJson function.
This commit is contained in:
parent
6c2838e8f4
commit
b2a4f563a0
4 changed files with 6 additions and 12 deletions
2
test/fixtures/readProjectFile.js
vendored
2
test/fixtures/readProjectFile.js
vendored
|
@ -7,6 +7,6 @@ module.exports = {
|
|||
},
|
||||
extractProjectJson: function (path) {
|
||||
const zip = new AdmZip(path);
|
||||
return zip.readAsText('project.json', 'utf8');
|
||||
return JSON.parse(zip.readAsText('project.json', 'utf8'));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ const extractProjectJson = require('../fixtures/readProjectFile').extractProject
|
|||
const VirtualMachine = require('../../src/index');
|
||||
|
||||
const uri = path.resolve(__dirname, '../fixtures/default.sb2');
|
||||
const project = JSON.parse(extractProjectJson(uri));
|
||||
const project = extractProjectJson(uri);
|
||||
|
||||
test('default', t => {
|
||||
const vm = new VirtualMachine();
|
||||
|
|
|
@ -15,15 +15,13 @@ test('spec', t => {
|
|||
test('default', t => {
|
||||
// Get SB2 JSON (string)
|
||||
const uri = path.resolve(__dirname, '../fixtures/default.sb2');
|
||||
const file = extractProjectJson(uri);
|
||||
const json = JSON.parse(file);
|
||||
const json = extractProjectJson(uri);
|
||||
|
||||
// Create runtime instance & load SB2 into it
|
||||
const rt = new runtime();
|
||||
rt.attachStorage(makeTestStorage());
|
||||
sb2.deserialize(json, rt).then(({targets}) => {
|
||||
// Test
|
||||
t.type(file, 'string');
|
||||
t.type(json, 'object');
|
||||
t.type(rt, 'object');
|
||||
t.type(targets, 'object');
|
||||
|
|
|
@ -15,14 +15,12 @@ test('spec', t => {
|
|||
test('default', t => {
|
||||
// Get SB2 JSON (string)
|
||||
const uri = path.resolve(__dirname, '../fixtures/default.sb2');
|
||||
const file = extractProjectJson(uri);
|
||||
const json = JSON.parse(file);
|
||||
const json = extractProjectJson(uri);
|
||||
|
||||
// Create runtime instance & load SB2 into it
|
||||
const rt = new Runtime();
|
||||
sb2.deserialize(json, rt).then(({targets}) => {
|
||||
// Test
|
||||
t.type(file, 'string');
|
||||
t.type(json, 'object');
|
||||
t.type(rt, 'object');
|
||||
t.type(targets, 'object');
|
||||
|
@ -55,8 +53,7 @@ test('default', t => {
|
|||
test('data scoping', t => {
|
||||
// Get SB2 JSON (string)
|
||||
const uri = path.resolve(__dirname, '../fixtures/data.sb2');
|
||||
const file = extractProjectJson(uri);
|
||||
const json = JSON.parse(file);
|
||||
const json = extractProjectJson(uri);
|
||||
|
||||
// Create runtime instance & load SB2 into it
|
||||
const rt = new Runtime();
|
||||
|
@ -72,8 +69,7 @@ test('data scoping', t => {
|
|||
test('whenclicked blocks imported separately', t => {
|
||||
// This sb2 fixture has a single "whenClicked" block on both sprite and stage
|
||||
const uri = path.resolve(__dirname, '../fixtures/when-clicked.sb2');
|
||||
const file = extractProjectJson(uri);
|
||||
const json = JSON.parse(file);
|
||||
const json = extractProjectJson(uri);
|
||||
|
||||
// Create runtime instance & load SB2 into it
|
||||
const rt = new Runtime();
|
||||
|
|
Loading…
Reference in a new issue