Skip to content

Commit c46c67d

Browse files
committed
fix: restructure vm initialization in test
1 parent 34259ae commit c46c67d

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

packages/scratch-vm/test/integration/monitors_sb2_to_sb3.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,14 @@ const makeTestStorage = require('../fixtures/make-test-storage');
44
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
55
const VirtualMachine = require('../../src/index');
66

7-
let vm;
7+
const projectUri = path.resolve(__dirname, '../fixtures/monitors.sb2');
8+
const project = readFileToBuffer(projectUri);
89

9-
tap.beforeEach(() => {
10-
const projectUri = path.resolve(__dirname, '../fixtures/monitors.sb2');
11-
const project = readFileToBuffer(projectUri);
12-
13-
vm = new VirtualMachine();
14-
vm.attachStorage(makeTestStorage());
15-
16-
// TODO figure out why running threads doesn't work in this test
17-
// vm.start();
18-
vm.clear();
19-
vm.setCompatibilityMode(false);
20-
vm.setTurboMode(false);
21-
22-
return vm.loadProject(project);
23-
});
2410
const test = tap.test;
2511

2612
test('saving and loading sb2 project with monitors preserves sliderMin and sliderMax', t => {
13+
const vm = new VirtualMachine();
14+
vm.attachStorage(makeTestStorage());
2715

2816
vm.on('playgroundData', e /* eslint-disable-line no-unused-vars */ => {
2917
// TODO related to above TODO, comment these back in when we figure out
@@ -139,13 +127,18 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide
139127
t.equal(monitorRecord.spriteName, null);
140128
t.equal(monitorRecord.targetId, null);
141129

130+
vm.quit();
142131
t.end();
143132
});
144133

145134
// Start VM, load project, and run
146135
t.doesNotThrow(() => {
147-
const sb3ProjectJson = vm.toJSON();
148-
return vm.loadProject(sb3ProjectJson).then(() => {
136+
vm.start();
137+
vm.clear();
138+
vm.setCompatibilityMode(false);
139+
vm.setTurboMode(false);
140+
return vm.loadProject(project).then(() => {
141+
vm.greenFlag();
149142
setTimeout(() => {
150143
vm.getPlaygroundData();
151144
vm.stopAll();

0 commit comments

Comments
 (0)