mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Make sure to set comment property of block when creating a new block via XML using the adapter. Update unit tests.
This commit is contained in:
parent
29b79878bc
commit
76b423e481
3 changed files with 33 additions and 0 deletions
|
@ -86,6 +86,11 @@ const domToBlock = function (blockDOM, blocks, isTopBlock, parent) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'comment':
|
||||||
|
{
|
||||||
|
block.comment = xmlChild.attribs.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'value':
|
case 'value':
|
||||||
case 'statement':
|
case 'statement':
|
||||||
{
|
{
|
||||||
|
|
13
test/fixtures/events.json
vendored
13
test/fixtures/events.json
vendored
|
@ -12,6 +12,19 @@
|
||||||
"!6Ahqg4f}Ljl}X5Hws?Z"
|
"!6Ahqg4f}Ljl}X5Hws?Z"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"createComment": {
|
||||||
|
"workspaceId": "7Luws3lyb*Z98~Kk+IG|",
|
||||||
|
"group": ";OswyM#@%`%,xOrhOXC=",
|
||||||
|
"recordUndo": true,
|
||||||
|
"name": "block",
|
||||||
|
"xml": {
|
||||||
|
"outerHTML": "<block type=\"wedo_motorclockwise\" id=\"z!+#Nqr,_(V=xz0y7a@d\"><comment id=\"aCommentId\">Some comment text</comment><value name=\"DURATION\"><shadow type=\"math_number\" id=\"!6Ahqg4f}Ljl}X5Hws?Z\"><field name=\"NUM\">10</field></shadow></value></block>"
|
||||||
|
},
|
||||||
|
"ids": [
|
||||||
|
"z!+#Nqr,_(V=xz0y7a@d",
|
||||||
|
"!6Ahqg4f}Ljl}X5Hws?Z"
|
||||||
|
]
|
||||||
|
},
|
||||||
"createbranch": {
|
"createbranch": {
|
||||||
"name": "block",
|
"name": "block",
|
||||||
"xml": {
|
"xml": {
|
||||||
|
|
|
@ -24,6 +24,7 @@ test('create event', t => {
|
||||||
// Outer block
|
// Outer block
|
||||||
t.type(result[0].id, 'string');
|
t.type(result[0].id, 'string');
|
||||||
t.type(result[0].opcode, 'string');
|
t.type(result[0].opcode, 'string');
|
||||||
|
t.type(result[0].comment, 'undefined');
|
||||||
t.type(result[0].fields, 'object');
|
t.type(result[0].fields, 'object');
|
||||||
t.type(result[0].inputs, 'object');
|
t.type(result[0].inputs, 'object');
|
||||||
t.type(result[0].inputs.DURATION, 'object');
|
t.type(result[0].inputs.DURATION, 'object');
|
||||||
|
@ -43,6 +44,20 @@ test('create event', t => {
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('create with comment', t => {
|
||||||
|
const result = adapter(events.createComment);
|
||||||
|
|
||||||
|
// This test should be the same as above except that it also has a comment.
|
||||||
|
|
||||||
|
t.ok(Array.isArray(result));
|
||||||
|
t.equal(result.length, 2);
|
||||||
|
|
||||||
|
t.type(result[0].comment, 'string');
|
||||||
|
t.equal(result[0].comment, 'aCommentId');
|
||||||
|
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
test('create with branch', t => {
|
test('create with branch', t => {
|
||||||
const result = adapter(events.createbranch);
|
const result = adapter(events.createbranch);
|
||||||
// Outer block
|
// Outer block
|
||||||
|
|
Loading…
Reference in a new issue