Skip to content

Commit aa8ea7f

Browse files
authored
test(Mover): Add test for moving complex expression blocks right/left move tests (#711)
* feat(tests): Introduce appendBlock test helper Creaet a new test helper appendBlock, that will create a new block from JSON and connect it as requested. * refactor(tests): Use appendBlock in statement move tests This means the test blocks don't need to include the block(s) to be moved. * refactor(tests): Use appendBlock in value move tests This means the test blocks don't need to include the block(s) to be moved, which considerably simplifies adding several more test cases. * chore(tests): Improve value move tests checking vs. unconnected block Use an unconnected (top-level) block with two empty value inputs, to allow us to better compare order of visiting inputs vs. outputs of top-level blocks. * test(Mover): Add complex expression right/left move tests
1 parent 1ff6012 commit aa8ea7f

File tree

2 files changed

+253
-192
lines changed

2 files changed

+253
-192
lines changed

test/loadTestBlocks.js

Lines changed: 62 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,10 @@ const moveStartTestBlocks = {
870870
},
871871
};
872872

873-
// A bunch of statement blocks. The blocks with IDs simple_mover and
874-
// complex_mover will be (constrained-)moved up, down, left and right
875-
// to verify that they visit all the expected candidate connections.
873+
// A bunch of statement blocks. It is intended that statement blocks
874+
// to be moved can be attached to the next connection of p5_canvas,
875+
// and then be (constrained-)moved up, down, left and right to verify
876+
// that they visit all the expected candidate connections.
876877
const moveStatementTestBlocks = {
877878
'blocks': {
878879
'languageVersion': 0,
@@ -894,24 +895,6 @@ const moveStatementTestBlocks = {
894895
'WIDTH': 400,
895896
'HEIGHT': 400,
896897
},
897-
'next': {
898-
'block': {
899-
'type': 'draw_emoji',
900-
'id': 'simple_mover',
901-
'fields': {
902-
'emoji': '✨',
903-
},
904-
'next': {
905-
'block': {
906-
'type': 'controls_if',
907-
'id': 'complex_mover',
908-
'extraState': {
909-
'hasElse': true,
910-
},
911-
},
912-
},
913-
},
914-
},
915898
},
916899
},
917900
},
@@ -1000,123 +983,92 @@ const moveValueTestBlocks = {
1000983
},
1001984
},
1002985
{
1003-
'type': 'text',
1004-
'id': 'unattached',
986+
'type': 'text_join',
987+
'id': 'join0',
1005988
'x': 75,
1006989
'y': 200,
1007-
'fields': {
1008-
'TEXT': 'unattached value',
1009-
},
1010990
},
1011991
{
1012992
'type': 'p5_draw',
1013993
'id': 'p5_draw',
1014994
'x': 75,
1015-
'y': 260,
995+
'y': 300,
1016996
'deletable': false,
1017997
'inputs': {
1018998
'STATEMENTS': {
1019999
'block': {
10201000
'type': 'text_print',
1021-
'id': 'print0',
1022-
'inputs': {
1023-
'TEXT': {
1024-
'block': {
1025-
'type': 'text_changeCase',
1026-
'id': 'complex_mover',
1027-
'fields': {
1028-
'CASE': 'TITLECASE',
1029-
},
1030-
'inputs': {
1031-
'TEXT': {
1032-
'block': {
1033-
'type': 'text',
1034-
'id': 'simple_mover',
1035-
'fields': {
1036-
'TEXT': 'simple mover',
1037-
},
1001+
'id': 'print1',
1002+
'next': {
1003+
'block': {
1004+
'type': 'text_print',
1005+
'id': 'print2',
1006+
'inputs': {
1007+
'TEXT': {
1008+
'shadow': {
1009+
'type': 'text',
1010+
'id': 'shadow_print2',
1011+
'fields': {
1012+
'TEXT': 'shadow',
10381013
},
10391014
},
10401015
},
10411016
},
1042-
},
1043-
},
1044-
'next': {
1045-
'block': {
1046-
'type': 'text_print',
1047-
'id': 'print1',
10481017
'next': {
10491018
'block': {
1050-
'type': 'text_print',
1051-
'id': 'print2',
1052-
'inputs': {
1053-
'TEXT': {
1054-
'shadow': {
1055-
'type': 'text',
1056-
'id': 'shadow_print2',
1057-
'fields': {
1058-
'TEXT': 'shadow',
1059-
},
1060-
},
1061-
},
1019+
'type': 'draw_emoji',
1020+
'id': 'draw_emoji',
1021+
'fields': {
1022+
'emoji': '🐻',
10621023
},
10631024
'next': {
10641025
'block': {
1065-
'type': 'draw_emoji',
1066-
'id': 'draw_emoji',
1067-
'fields': {
1068-
'emoji': '🐻',
1026+
'type': 'text_print',
1027+
'id': 'print3',
1028+
'inputs': {
1029+
'TEXT': {
1030+
'block': {
1031+
'type': 'text_join',
1032+
'id': 'join1',
1033+
'inline': true,
1034+
'inputs': {
1035+
'ADD0': {
1036+
'shadow': {
1037+
'type': 'text',
1038+
'id': 'shadow_join',
1039+
'fields': {
1040+
'TEXT': 'inline',
1041+
},
1042+
},
1043+
},
1044+
},
1045+
},
1046+
},
10691047
},
10701048
'next': {
10711049
'block': {
1072-
'type': 'text_print',
1073-
'id': 'print3',
1050+
'type': 'controls_repeat_ext',
1051+
'id': 'controls_repeat_ext',
10741052
'inputs': {
1075-
'TEXT': {
1076-
'block': {
1077-
'type': 'text_join',
1078-
'id': 'text_join1',
1079-
'inline': true,
1080-
'inputs': {
1081-
'ADD0': {
1082-
'shadow': {
1083-
'type': 'text',
1084-
'id': 'shadow_join',
1085-
'fields': {
1086-
'TEXT': 'inline',
1087-
},
1088-
},
1089-
},
1053+
'TIMES': {
1054+
'shadow': {
1055+
'type': 'math_number',
1056+
'id': 'shadow_repeat',
1057+
'fields': {
1058+
'NUM': 1,
10901059
},
10911060
},
10921061
},
1093-
},
1094-
'next': {
1095-
'block': {
1096-
'type': 'controls_repeat_ext',
1097-
'id': 'controls_repeat_ext',
1098-
'inputs': {
1099-
'TIMES': {
1100-
'shadow': {
1101-
'type': 'math_number',
1102-
'id': 'shadow_repeat',
1103-
'fields': {
1104-
'NUM': 1,
1105-
},
1106-
},
1107-
},
1108-
'DO': {
1109-
'block': {
1110-
'type': 'text_print',
1111-
'id': 'print4',
1112-
'inputs': {
1113-
'TEXT': {
1114-
'block': {
1115-
'type': 'text_join',
1116-
'id': 'text_join2',
1117-
'inline': false,
1118-
},
1119-
},
1062+
'DO': {
1063+
'block': {
1064+
'type': 'text_print',
1065+
'id': 'print4',
1066+
'inputs': {
1067+
'TEXT': {
1068+
'block': {
1069+
'type': 'text_join',
1070+
'id': 'join2',
1071+
'inline': false,
11201072
},
11211073
},
11221074
},

0 commit comments

Comments
 (0)