Test for CREATE event with substack

This commit is contained in:
Tim Mickel 2016-06-07 10:49:12 -04:00
parent f158af18b1
commit 4eb63cf33e
2 changed files with 35 additions and 0 deletions
test

View file

@ -11,5 +11,16 @@
"z!+#Nqr,_(V=xz0y7a@d",
"!6Ahqg4f}Ljl}X5Hws?Z"
]
},
"createsubstack": {
"name": "block",
"xml": {
"outerHTML": "<block type=\"control_forever\" id=\"r9`RpL74T6*SXPKv7}Dq\" x=\"61\" y=\"90\"><statement name=\"SUBSTACK\"><block type=\"control_wait\" id=\"{Rwt[LFtD1-JPAi-qf:.\"><value name=\"DURATION\"><shadow type=\"math_number\" id=\"VMDxt_9SYe5{*eNRe5dZ\"><field name=\"NUM\">1</field></shadow></value></block></statement></block>"
},
"ids": [
"r9`RpL74T6*SXPKv7}Dq",
"{Rwt[LFtD1-JPAi-qf:.",
"VMDxt_9SYe5{*eNRe5dZ"
]
}
}

View file

@ -34,3 +34,27 @@ test('create event', function (t) {
t.end();
});
test('create with substack', function (t) {
var result = adapter(events.createsubstack);
// Outer block
t.type(result[0].id, 'string');
t.type(result[0].opcode, 'string');
t.type(result[0].fields, 'object');
t.type(result[0].inputs, 'object');
t.type(result[0].inputs['SUBSTACK'], 'object');
t.type(result[0].topLevel, 'boolean');
t.equal(result[0].topLevel, true);
// In substack
var substackBlockId = result[0].inputs['SUBSTACK']['block'];
t.type(substackBlockId, 'string');
// Find actual substack block
var substackBlock = null;
for (var i = 0; i < result.length; i++) {
if (result[i].id == substackBlockId) {
substackBlock = result[i];
}
}
t.type(substackBlock, 'object');
t.end();
});