mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Add blocks delete chain test
This commit is contained in:
parent
06eaee9108
commit
855caab8d2
1 changed files with 40 additions and 0 deletions
|
@ -95,3 +95,43 @@ test('delete', function (t) {
|
|||
t.equal(b._stacks.indexOf('foo'), -1);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('delete chain', function (t) {
|
||||
// Create a chain of connected blocks and delete the top one.
|
||||
// All of them should be deleted.
|
||||
var b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
next: 'foo2',
|
||||
fields: {},
|
||||
inputs: {},
|
||||
topLevel: true
|
||||
});
|
||||
b.createBlock({
|
||||
id: 'foo2',
|
||||
opcode: 'TEST_BLOCK',
|
||||
next: 'foo3',
|
||||
fields: {},
|
||||
inputs: {},
|
||||
topLevel: false
|
||||
});
|
||||
b.createBlock({
|
||||
id: 'foo3',
|
||||
opcode: 'TEST_BLOCK',
|
||||
next: null,
|
||||
fields: {},
|
||||
inputs: {},
|
||||
topLevel: false
|
||||
});
|
||||
b.deleteBlock({
|
||||
id: 'foo'
|
||||
});
|
||||
t.type(b._blocks['foo'], 'undefined');
|
||||
t.type(b._blocks['foo2'], 'undefined');
|
||||
t.type(b._blocks['foo3'], 'undefined');
|
||||
t.equal(b._stacks.indexOf('foo'), -1);
|
||||
t.equal(Object.keys(b._blocks).length, 0);
|
||||
t.equal(b._stacks.length, 0);
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue