mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-07 11:34:00 -04:00
Add tests for project changed state.
This commit is contained in:
parent
a9cf509a55
commit
df823a06f6
5 changed files with 318 additions and 0 deletions
test/unit
30
test/unit/project_load_changed_state.js
Normal file
30
test/unit/project_load_changed_state.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const tap = require('tap');
|
||||
const path = require('path');
|
||||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
||||
const makeTestStorage = require('../fixtures/make-test-storage');
|
||||
const VirtualMachine = require('../../src/virtual-machine');
|
||||
|
||||
tap.tearDown(() => process.nextTick(process.exit));
|
||||
|
||||
const test = tap.test;
|
||||
|
||||
// Test that loading a project does not emit a project change
|
||||
// This is in its own file so that it does not affect the test setup
|
||||
// and results of the other project changed state tests
|
||||
test('Loading a project should not emit a project changed event', t => {
|
||||
const projectUri = path.resolve(__dirname, '../fixtures/default.sb2');
|
||||
const project = readFileToBuffer(projectUri);
|
||||
|
||||
const vm = new VirtualMachine();
|
||||
|
||||
let projectChanged = false;
|
||||
vm.runtime.addListener('PROJECT_CHANGED', () => {
|
||||
projectChanged = true;
|
||||
});
|
||||
|
||||
vm.attachStorage(makeTestStorage());
|
||||
return vm.loadProject(project).then(() => {
|
||||
t.equal(projectChanged, false);
|
||||
t.end();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue