Fix loading broadcast messages with special characters for projects that were converted from 2.0.

This commit is contained in:
picklesrus 2019-02-06 16:58:46 -05:00
parent aead1ba8f4
commit b904f19c1d
8 changed files with 135 additions and 12 deletions

View file

@ -809,3 +809,35 @@ test('getAllVariableAndListReferences returns references when variable blocks ex
t.end();
});
test('getAllVariableAndListReferences does not return broadcast blocks if the flag is left out', t => {
const b = new Blocks(new Runtime());
b.createBlock(adapter(events.mockBroadcastBlock)[0]);
b.createBlock(adapter(events.mockBroadcastBlock)[1]);
t.equal(Object.keys(b.getAllVariableAndListReferences()).length, 0);
t.end();
});
test('getAllVariableAndListReferences returns broadcast when we tell it to', t => {
const b = new Blocks(new Runtime());
b.createBlock(adapter(events.mockVariableBlock)[0]);
// Make the broadcast block and its shadow (which includes the actual broadcast field).
b.createBlock(adapter(events.mockBroadcastBlock)[0]);
b.createBlock(adapter(events.mockBroadcastBlock)[1]);
const varListRefs = b.getAllVariableAndListReferences(null, true);
t.equal(Object.keys(varListRefs).length, 2);
t.equal(Array.isArray(varListRefs['mock var id']), true);
t.equal(varListRefs['mock var id'].length, 1);
t.equal(varListRefs['mock var id'][0].type, Variable.SCALAR_TYPE);
t.equal(varListRefs['mock var id'][0].referencingField.value, 'a mock variable');
t.equal(Array.isArray(varListRefs['mock broadcast message id']), true);
t.equal(varListRefs['mock broadcast message id'].length, 1);
t.equal(varListRefs['mock broadcast message id'][0].type, Variable.BROADCAST_MESSAGE_TYPE);
t.equal(varListRefs['mock broadcast message id'][0].referencingField.value, 'my message');
t.end();
});