| 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 projectUri = path.resolve(__dirname, '../fixtures/block-to-workspace-comments.sb2'); |
| const project = readFileToBuffer(projectUri); |
|
|
| test('importing sb2 project where block comment is converted to workspace comment and block is deleted', t => { |
| const vm = new VirtualMachine(); |
| vm.attachStorage(makeTestStorage()); |
|
|
| |
| vm.on('playgroundData', e => { |
| const threads = JSON.parse(e.threads); |
| t.equal(threads.length, 0); |
|
|
| const target = vm.runtime.targets[1]; |
|
|
| |
| |
| const targetComments = Object.values(target.comments); |
| t.equal(targetComments.length, 3); |
| const spriteWorkspaceComments = targetComments.filter(comment => comment.blockId === null); |
| t.equal(spriteWorkspaceComments.length, 2); |
|
|
| |
| const blockComments = targetComments.filter(comment => !!comment.blockId); |
| t.equal(blockComments.length, 1); |
|
|
| |
| const invalidComments = targetComments.filter(comment => typeof comment.blockId === 'number'); |
| t.equal(invalidComments.length, 0); |
|
|
| t.end(); |
| process.nextTick(process.exit); |
| }); |
|
|
| |
| t.doesNotThrow(() => { |
| vm.start(); |
| vm.clear(); |
| vm.setCompatibilityMode(false); |
| vm.setTurboMode(false); |
| vm.loadProject(project).then(() => { |
| vm.greenFlag(); |
| setTimeout(() => { |
| vm.getPlaygroundData(); |
| vm.stopAll(); |
| }, 100); |
| }); |
| }); |
| }); |
|
|