@@ -4,26 +4,14 @@ const makeTestStorage = require('../fixtures/make-test-storage');
44const readFileToBuffer = require ( '../fixtures/readProjectFile' ) . readFileToBuffer ;
55const 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- } ) ;
2410const test = tap . test ;
2511
2612test ( '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