Best JavaScript code snippet using appium-android-driver
grid-moving-columns.js
Source:grid-moving-columns.js
...784 // (although they're not called directly). The point is to abstract as much as possible so the785 // dev doesn't need to call makeGrid(), dragColumn() or any other helper function so a spec786 // can be quickly and easily written.787 //788 // The runTest() API is the only function that the dev needs to worry about. This function789 // takes two arguments, the second of which is optional:790 //791 // runTest(Object specConfig, Function additionalTests);792 //793 // In addition, it can take the following configs:794 // columns = The grid columns.795 // dropPosition = (defaults to 'after')796 // locked = Specify `true` for locking grids.797 // order = The expected order of headers AND view columns after all moves have run.798 // range = The range of moves. Only specify a range or a sequence, not both.799 // sequence = The sequence of moves. Only specify a range or a sequence, not both.800 // subGroupHeader = The sub group header below the groupHeader.801 // onRight = This is dependent upon the dropPosition, i.e.:802 //803 // `dropPosition === 'before' ? false : true;`804 //805 // groupHeader = This will default to the first groupHeader in the grid unless specified here.806 //807 // NOTE: See the section 'Accessing Group Headers' to understand how to reference any group headers808 // needed for any test.809 //810 // --------------811 // :: Examples ::812 // --------------813 //814 // Here is an example of a test that will move a range of columns in order, one after the other:815 //816 // runTest({817 // columns: columns,818 // dropPosition: 'before',819 // order: '1,2,3,4,5,6,7,8',820 // range: [2, 5]821 // }, additionalSpec);822 //823 // Here is an example of a test that will runs a sequence of column moves (most common):824 //825 // runTest({826 // columns: columns,827 // order: '1,2,6,11,12,13,5,4,3,7,8,9,10',828 // sequence: [829 // [8, 12, false],830 // [5, 7, false],831 // ['groupHeader', 10, false],832 // [13, 9, false]833 // ],834 // }, additionalSpec);835 //836 // Note that the sequence can be in any order and can reference group headers, as well.837 //838 // -----------------------------839 // :: Accessing Group Headers ::840 // -----------------------------841 //842 // If you want to have access to the subGroupHeader variable, then configure your843 // test so `subGroupHeader` is defined, the ordinal will be the number of levels deep844 // in the CQ query, i.e., rootHeaderCt.query('[isGroupHeader'])[subGroupHeader].845 // You can then use this to reference the contents of the subGroupHeader in your846 // sequence, i.e., [1, 'subGroupHeader', false].847 // NOTE:848 // `groupHeader` will refer to the first group header in the header container.849 // `subGroupHeader` will refer to the group header that subGroupHeader references,850 // otherwise it will also point to groupHeader.851 //852 // If you need to reference nested group headers below the first group header, you'll853 // need to tell the test which nested group header should be referenced by the groupHeader854 // variable. You can do this by specifying groupHeader in your test config.855 //856 // For example, if you have 3 nested groups, you can reference the deepest group header857 // and the second nested group header like this:858 //859 // runTest({860 // columns: columns,861 // order: '1,2,6,7,8,9,3,4,5,10,11,12,13,14,15,16',862 // sequence: [863 // ['subGroupHeader', 'groupHeader', false]864 // ],865 // groupHeader: 1,866 // subGroupHeader: 2867 // }, function () {868 // expect(groupHeader.ownerCt).toBe(null);869 // });870 //871 // Note that `dropPosition` only needs to be declared if using a range.872 //873 var columns, dropPosition, order, range, sequence, subGroupHeader, onRight, stateful, skipMove;874 function runTest(cfg, expectMore) {875 setVars(cfg);876 // Note: I didn't include a way to configure the grid for these tests.877 // This could be a TODO item, but I didn't see the necessity of it.878 makeGrid(columns, null, {879 enableColumnResize: false,880 header: false,881 stateful: stateful,882 stateId: 'quux'883 });884 // skipMove is useful when testing grid state for stateful unit tests.885 if (!skipMove) {886 doMove();887 }888 testUI(order);889 if (expectMore) {890 expectMore();891 }892 // Save state for stateful unit tests.893 if (stateful) {894 grid.saveState();895 }896 grid.destroy();897 // Null out the refs in case multiple tests are run in a single 'if' block.898 groupHeader = subGroupHeader = null;899 }900 function setVars(cfg) {901 cfg = cfg || {};902 columns = cfg.columns;903 dropPosition = cfg.dropPosition || 'after';904 locked = cfg.locked;905 order = cfg.order;906 range = cfg.range;907 sequence = cfg.sequence;908 skipMove = cfg.skipMove;909 stateful = cfg.stateful;910 subGroupHeader = cfg.subGroupHeader;911 onRight = dropPosition === 'before' ? false : true;912 if (cfg.groupHeader) {913 groupHeader = cfg.groupHeader;914 }915 }916 function doMove() {917 if (range) {918 dragRange();919 } else {920 dragSequence();921 }922 }923 function dragRange() {924 var begin = range[0],925 end = range[1];926 if (begin === end) {927 return;928 }929 setGroupHeaders();930 if (begin > end) {931 for (; begin >= end; begin--) {932 dragColumn(visibleColumns[begin], subGroupHeader, onRight);933 }934 } else {935 for (; begin <= end; begin++) {936 dragColumn(visibleColumns[begin], subGroupHeader, onRight);937 }938 }939 }940 function dragSequence() {941 var headers, i, len, pos, zero, one, from, to;942 setGroupHeaders();943 // 'groupHeader' and 'subGroupHeader' need to be able to be values in944 // test sequences, so look them up now.945 headers = {946 'groupHeader': groupHeader,947 'subGroupHeader': subGroupHeader948 };949 for (i = 0, len = sequence.length; i < len; i++) {950 pos = sequence[i];951 zero = pos[0];952 one = pos[1];953 from = (typeof zero === 'string') ?954 headers[zero] :955 visibleColumns[zero];956 to = (typeof one === 'string') ?957 headers[one] :958 visibleColumns[one];959 dragColumn(from, to, pos[2]);960 }961 }962 function setGroupHeaders() {963 groupHeader = (typeof groupHeader === 'number') ?964 // Use grid since we operate on locked grids, too.965 grid.query('[isGroupHeader]')[groupHeader] :966 groupHeader;967 subGroupHeader = (typeof subGroupHeader === 'number') ?968 // Use grid since we operate on locked grids, too.969 grid.query('[isGroupHeader]')[subGroupHeader] :970 groupHeader;971 }972 afterEach(function () {973 columns = dropPosition = subGroupHeader = order = range = sequence = subGroupHeader = onRight = stateful = skipMove = null;974 });975 describe('stateful', function () {976 var columns;977 beforeEach(function () {978 columns = [{979 dataIndex: 'field1',980 stateId: 'foo1',981 header: 'Field1'982 }, {983 dataIndex: 'field2',984 stateId: 'foo2',985 header: 'Field2'986 }, {987 header: 'Group1',988 stateId: 'foo3',989 columns: [{990 dataIndex: 'field3',991 stateId: 'foo4',992 header: 'Field3'993 }, {994 dataIndex: 'field4',995 stateId: 'foo5',996 header: 'Field4'997 }, {998 dataIndex: 'field5',999 stateId: 'foo6',1000 header: 'Field5'1001 }, {1002 dataIndex: 'field6',1003 stateId: 'foo7',1004 header: 'Field6'1005 }]1006 }, {1007 dataIndex: 'field7',1008 stateId: 'foo8',1009 header: 'Field7'1010 }, {1011 dataIndex: 'field8',1012 stateId: 'foo9',1013 header: 'Field8'1014 }];1015 new Ext.state.Provider();1016 });1017 afterEach(function () {1018 Ext.state.Manager.getProvider().clear();1019 columns = null;1020 });1021 it('should work when moving headers within a grouped header', function () {1022 runTest({1023 columns: columns,1024 order: '1,2,4,5,6,3,7,8',1025 // Move the first subheader in the first group to be the last subheader in the same group.1026 sequence: [1027 [2, 5, true]1028 ],1029 stateful: true1030 });1031 runTest({1032 columns: columns,1033 order: '1,2,4,5,6,3,7,8',1034 skipMove: true,1035 stateful: true1036 });1037 });1038 });1039 describe('one nested group', function () {1040 var columns = [{1041 dataIndex: 'field1',1042 header: 'Field1'1043 }, {1044 dataIndex: 'field2',1045 header: 'Field2'1046 }, {1047 header: 'Group1',1048 columns: [{1049 dataIndex: 'field3',1050 header: 'Field3'1051 }, {1052 dataIndex: 'field4',1053 header: 'Field4'1054 }, {1055 dataIndex: 'field5',1056 header: 'Field5'1057 }, {1058 dataIndex: 'field6',1059 header: 'Field6'1060 }]1061 }, {1062 dataIndex: 'field7',1063 header: 'Field7'1064 }, {1065 dataIndex: 'field8',1066 header: 'Field8'1067 }];1068 describe('dragging all subheaders out of the group', function () {1069 describe('when the targetHeader is the groupHeader', function () {1070 function additionalSpec() {1071 expect(groupHeader.rendered).toBe(false);1072 expect(groupHeader.ownerCt).toBe(null);1073 }1074 // Each spec will test that the groupHeader has been removed after the last subheader.1075 it('should work when the move position is before the target header', function () {1076 runTest({1077 columns: columns,1078 dropPosition: 'before',1079 order: '1,2,3,4,5,6,7,8',1080 range: [2, 5]1081 }, additionalSpec);1082 });1083 it('should work when the move position is before the target header, in reverse', function () {1084 runTest({1085 columns: columns,1086 order: '1,2,6,5,4,3,7,8',1087 sequence: [1088 [5, 'groupHeader', false],1089 [5, 'groupHeader', false],1090 [5, 'groupHeader', false],1091 [5, 'groupHeader', false]1092 ]1093 }, additionalSpec);1094 });1095 it('should work when the move position is after the target header', function () {1096 runTest({1097 columns: columns,1098 order: '1,2,6,5,4,3,7,8',1099 sequence: [1100 [2, 'groupHeader', true],1101 [2, 'groupHeader', true],1102 [2, 'groupHeader', true],1103 [2, 'groupHeader', true]1104 ]1105 }, additionalSpec);1106 });1107 it('should work when the move position is after the target header, in reverse', function () {1108 runTest({1109 columns: columns,1110 dropPosition: 'right',1111 order: '1,2,3,4,5,6,7,8',1112 range: [5, 2]1113 }, additionalSpec);1114 });1115 it("should work when the move position alternates between 'before' and 'after'", function () {1116 runTest({1117 columns: columns,1118 order: '1,2,4,3,6,5,7,8',1119 sequence: [1120 // [from, to, onRight]1121 // null === groupHeader1122 [4, 'groupHeader', true],1123 [3, 'groupHeader', false],1124 [3, 'groupHeader', false],1125 [4, 'groupHeader', true]1126 ]1127 }, additionalSpec);1128 });1129 });1130 });1131 describe('when the headers are moved randomly', function () {1132 it("should work when the move position is 'before'", function () {1133 runTest({1134 columns: columns,1135 order: '6,1,3,4,2,5,7,8',1136 sequence: [1137 [3, 1, false],1138 [4, 6, false],1139 [4, 0, false],1140 [4, 2, false]1141 ]1142 });1143 });1144 it("should work when the move position is 'after'", function () {1145 runTest({1146 columns: columns,1147 order: '1,6,2,3,4,7,5,8',1148 sequence: [1149 [3, 1, true],1150 [4, 6, true],1151 [4, 0, true],1152 [4, 2, true]1153 ]1154 });1155 });1156 it("should work when the move position alternates between 'before' and 'after'", function () {1157 runTest({1158 columns: columns,1159 order: '6,1,4,3,2,7,5,8',1160 sequence: [1161 [3, 1, false],1162 [4, 6, true],1163 [4, 0, false],1164 [4, 2, true]1165 ]1166 });1167 });1168 });1169 describe('moving the group header', function () {1170 it('should move the group to the beginning of the root header container, before position', function () {1171 runTest({1172 columns: columns,1173 order: '3,4,5,6,1,2,7,8',1174 sequence: [1175 ['groupHeader', 0, false]1176 ]1177 });1178 });1179 it('should move the group to the beginning of the root header container, after position', function () {1180 runTest({1181 columns: columns,1182 order: '1,3,4,5,6,2,7,8',1183 sequence: [1184 ['groupHeader', 0, true]1185 ]1186 });1187 });1188 it('should move the group to the end of the root header container, before position', function () {1189 runTest({1190 columns: columns,1191 order: '1,2,7,3,4,5,6,8',1192 sequence: [1193 ['groupHeader', 7, false]1194 ]1195 });1196 });1197 it('should move the group to the end of the root header container, after position', function () {1198 runTest({1199 columns: columns,1200 order: '1,2,7,8,3,4,5,6',1201 sequence: [1202 ['groupHeader', 7, true]1203 ]1204 });1205 });1206 });1207 });1208 describe('two nested groups', function () {1209 var columns = [{1210 dataIndex: 'field1',1211 header: 'Field1'1212 }, {1213 dataIndex: 'field2',1214 header: 'Field2'1215 }, {1216 header: 'Group1',1217 columns: [{1218 dataIndex: 'field3',1219 header: 'Field3'1220 }, {1221 dataIndex: 'field4',1222 header: 'Field4'1223 }, {1224 dataIndex: 'field5',1225 header: 'Field5'1226 }, {1227 header: 'Group2',1228 columns: [{1229 dataIndex: 'field6',1230 header: 'Field6'1231 }, {1232 dataIndex: 'field7',1233 header: 'Field7'1234 }, {1235 dataIndex: 'field8',1236 header: 'Field8'1237 }, {1238 dataIndex: 'field9',1239 header: 'Field9'1240 }]1241 }, {1242 dataIndex: 'field10',1243 header: 'Field10'1244 }]1245 }, {1246 dataIndex: 'field11',1247 header: 'Field11'1248 }, {1249 dataIndex: 'field12',1250 header: 'Field12'1251 }, {1252 dataIndex: 'field13',1253 header: 'Field13'1254 }];1255 describe('dragging all subheaders out of Group2', function () {1256 describe('when the targetHeader is the Group2 groupHeader (so the drag is contiguous to Group2)', function () {1257 // Note: in order to target the correct subgroupheader, define a subGroupHeader config1258 // and then specify 'subGroupHeader' in the sequence.1259 //1260 // The group headers are looked up by:1261 //1262 // headerCt.query('[isGroupHeader]')[subGroupHeader];1263 //1264 // See setGroupHeaders().1265 //1266 // Similarly, for ranges, specify the subGroupHeader config in addition to the range1267 // config. See an example in the tests below.1268 //1269 // (Remember that groupHeader will refer to the first sub group header!)1270 function additionalSpec() {1271 expect(subGroupHeader.ownerCt).toBe(null);1272 expect(subGroupHeader.rendered).toBe(false);1273 }1274 it('should work when the move position is before the target header', function () {1275 runTest({1276 columns: columns,1277 dropPosition: 'before',1278 order: '1,2,3,4,5,6,7,8,9,10,11,12,13',1279 range: [5, 8],1280 subGroupHeader: 11281 });1282 });1283 it('should work when the move position is before the target header, in reverse', function () {1284 runTest({1285 columns: columns,1286 order: '1,2,3,4,5,9,8,7,6,10,11,12,13',1287 sequence: [1288 [8, 'subGroupHeader', false],1289 [8, 'subGroupHeader', false],1290 [8, 'subGroupHeader', false],1291 [8, 'subGroupHeader', false]1292 ],1293 subGroupHeader: 11294 });1295 });1296 it('should work when the move position is after the target header', function () {1297 runTest({1298 columns: columns,1299 order: '1,2,3,4,5,9,8,7,6,10,11,12,13',1300 sequence: [1301 [5, 'subGroupHeader', true],1302 [5, 'subGroupHeader', true],1303 [5, 'subGroupHeader', true],1304 [5, 'subGroupHeader', true]1305 ],1306 subGroupHeader: 11307 });1308 });1309 it('should work when the move position is after the target header, in reverse', function () {1310 runTest({1311 columns: columns,1312 dropPosition: 'right',1313 order: '1,2,3,4,5,6,7,8,9,10,11,12,13',1314 range: [8, 5],1315 subGroupHeader: 11316 });1317 });1318 it("should work when the move position alternates between 'before' and 'after'", function () {1319 runTest({1320 columns: columns,1321 order: '1,2,3,4,5,7,9,6,8,10,11,12,13',1322 sequence: [1323 [6, 'subGroupHeader', false],1324 [7, 'subGroupHeader', true],1325 [6, 'subGroupHeader', true],1326 [6, 'subGroupHeader', false]1327 ],1328 subGroupHeader: 11329 });1330 });1331 it("should remove the group header when the last subheader is removed, 'before' move position", function () {1332 runTest({1333 columns: columns,1334 dropPosition: 'before',1335 order: '1,2,3,4,5,6,7,8,9,10,11,12,13',1336 range: [5, 8],1337 subGroupHeader: 11338 }, additionalSpec);1339 });1340 it("should remove the group header when the last subheader is removed, 'after' move position", function () {1341 runTest({1342 columns: columns,1343 dropPosition: 'after',1344 order: '1,2,3,4,5,6,7,8,9,10,11,12,13',1345 range: [8, 5],1346 subGroupHeader: 11347 }, additionalSpec);1348 });1349 });1350 describe('when the Group2 subheaders are dragged into Group1 (targetHeader is not Group2)', function () {1351 it('should work when the move position is before the first subheader in Group1', function () {1352 runTest({1353 columns: columns,1354 order: '1,2,9,8,7,6,3,4,5,10,11,12,13',1355 sequence: [1356 [5, 2, false],1357 [6, 2, false],1358 [7, 2, false],1359 [8, 2, false]1360 ]1361 });1362 });1363 it('should work when the move position is before the first subheader in Group1, in reverse', function () {1364 runTest({1365 columns: columns,1366 order: '1,2,6,7,8,9,3,4,5,10,11,12,13',1367 sequence: [1368 [8, 2, false],1369 [8, 2, false],1370 [8, 2, false],1371 [8, 2, false]1372 ]1373 });1374 });1375 it('should work when the move position is after the last subheader in Group1', function () {1376 runTest({1377 columns: columns,1378 order: '1,2,3,4,5,10,6,7,8,9,11,12,13',1379 sequence: [1380 [5, 9, true],1381 [5, 9, true],1382 [5, 9, true],1383 [5, 9, true]1384 ]1385 });1386 });1387 it('should work when the move position is after the last subheader in Group1, in reverse', function () {1388 runTest({1389 columns: columns,1390 order: '1,2,3,4,5,10,9,8,7,6,11,12,13',1391 sequence: [1392 [8, 9, true],1393 [7, 9, true],1394 [6, 9, true],1395 [5, 9, true]1396 ]1397 });1398 });1399 it('should work when the move position is before the subheader directly after Group2', function () {1400 runTest({1401 columns: columns,1402 order: '1,2,3,4,5,9,8,7,6,10,11,12,13',1403 sequence: [1404 [5, 9, false],1405 [5, 8, false],1406 [5, 7, false],1407 [5, 6, false]1408 ]1409 });1410 });1411 it('should work when the move position is before the subheader directly after Group2, in reverse', function () {1412 runTest({1413 columns: columns,1414 order: '1,2,3,4,5,6,7,8,9,10,11,12,13',1415 sequence: [1416 [8, 9, false],1417 [7, 8, false],1418 [6, 7, false],1419 [5, 6, false]1420 ]1421 });1422 });1423 });1424 describe('when the Group2 subheaders are dragged into the root header container', function () {1425 function additionalSpec() {1426 expect(grid.down('[isGroupHeader][text=Group2]')).toBe(null);1427 }1428 // Note that not specifying a groupSubHeader with a range means that the groupHeader ref will1429 // be the first group found, which is Group1 and the one we want.1430 //1431 // Note that also we're testing that Group2 has been removed after the last subheader has been1432 // dragged out.1433 it('should work when the move position is before the first group header (Group1)', function () {1434 runTest({1435 columns: columns,1436 dropPosition: 'before',1437 order: '1,2,6,7,8,9,3,4,5,10,11,12,13',1438 range: [5, 8]1439 }, additionalSpec);1440 });1441 it('should work when the move position is before the first group header (Group1), in reverse', function () {1442 // Note that specifying null in a sequence and not specifying a subGroupHeader config will1443 // have the value of groupHeader default to be the first group header found, which is1444 // Group1 and the one we want.1445 runTest({1446 columns: columns,1447 order: '1,2,9,8,7,6,3,4,5,10,11,12,13',1448 sequence: [1449 [8, 'groupHeader', false],1450 [8, 'groupHeader', false],1451 [8, 'groupHeader', false],1452 [8, 'groupHeader', false]1453 ]1454 }, additionalSpec);1455 });1456 it('should work when the move position is after the first group header (Group1)', function () {1457 runTest({1458 columns: columns,1459 order: '1,2,3,4,5,10,9,8,7,6,11,12,13',1460 sequence: [1461 [5, 'groupHeader', true],1462 [5, 'groupHeader', true],1463 [5, 'groupHeader', true],1464 [5, 'groupHeader', true]1465 ]1466 }, additionalSpec);1467 });1468 it('should work when the move position is after the first group header (Group1), in reverse', function () {1469 runTest({1470 columns: columns,1471 dropPosition: 'right',1472 order: '1,2,3,4,5,10,6,7,8,9,11,12,13',1473 range: [8, 5]1474 }, additionalSpec);1475 });1476 it("should work when the move position alternates between 'before' and 'after'", function () {1477 runTest({1478 columns: columns,1479 order: '1,2,3,4,5,7,9,6,8,10,11,12,13',1480 sequence: [1481 [6, 'subGroupHeader', false],1482 [7, 'subGroupHeader', true],1483 [6, 'subGroupHeader', true],1484 [6, 'subGroupHeader', false]1485 ],1486 subGroupHeader: 11487 }, additionalSpec);1488 });1489 });1490 });1491 describe('moving the group header', function () {1492 describe('Group1', function () {1493 it('should move the group to the beginning of the root header container, before position', function () {1494 runTest({1495 columns: columns,1496 order: '3,4,5,6,7,8,9,10,1,2,11,12,13',1497 sequence: [1498 ['groupHeader', 0, false]1499 ]1500 });1501 });1502 it('should move the group to the beginning of the root header container, after position', function () {1503 runTest({1504 columns: columns,1505 order: '1,3,4,5,6,7,8,9,10,2,11,12,13',1506 sequence: [1507 ['groupHeader', 0, true]1508 ]1509 });1510 });1511 it('should move the group to the end of the root header container, before position', function () {1512 runTest({1513 columns: columns,1514 order: '1,2,11,12,3,4,5,6,7,8,9,10,13',1515 sequence: [1516 ['groupHeader', 12, false]1517 ]1518 });1519 });1520 it('should move the group to the end of the root header container, after position', function () {1521 runTest({1522 columns: columns,1523 order: '1,2,11,12,13,3,4,5,6,7,8,9,10',1524 sequence: [1525 ['groupHeader', 12, true]1526 ]1527 });1528 });1529 });1530 describe('Group2', function () {1531 it('should move the group to the beginning of the root header container, before position', function () {1532 runTest({1533 columns: columns,1534 order: '6,7,8,9,1,2,3,4,5,10,11,12,13',1535 sequence: [1536 ['subGroupHeader', 0, false]1537 ],1538 subGroupHeader: 11539 });1540 });1541 it('should move the group to the beginning of the root header container, after position', function () {1542 runTest({1543 columns: columns,1544 order: '1,6,7,8,9,2,3,4,5,10,11,12,13',1545 sequence: [1546 ['subGroupHeader', 0, true]1547 ],1548 subGroupHeader: 11549 });1550 });1551 it('should move the group to the end of the root header container, before position', function () {1552 runTest({1553 columns: columns,1554 order: '1,2,3,4,5,10,11,12,6,7,8,9,13',1555 sequence: [1556 ['subGroupHeader', 12, false]1557 ],1558 subGroupHeader: 11559 });1560 });1561 it('should move the group to the end of the root header container, after position', function () {1562 runTest({1563 columns: columns,1564 order: '1,2,3,4,5,10,11,12,13,6,7,8,9',1565 sequence: [1566 ['subGroupHeader', 12, true]1567 ],1568 subGroupHeader: 11569 });1570 });1571 it('should move the group to the beginning of Group1', function () {1572 runTest({1573 columns: columns,1574 order: '1,2,6,7,8,9,3,4,5,10,11,12,13',1575 sequence: [1576 ['subGroupHeader', 2, false]1577 ],1578 subGroupHeader: 11579 });1580 });1581 it('should move the group to the end of Group1', function () {1582 runTest({1583 columns: columns,1584 order: '1,2,3,4,5,10,6,7,8,9,11,12,13',1585 sequence: [1586 ['subGroupHeader', 9, true]1587 ],1588 subGroupHeader: 11589 });1590 });1591 });1592 describe('when the nested groups are stacked directly on top of each other', function () {1593 var columns = [{1594 dataIndex: 'field1',1595 header: 'Field1'1596 }, {1597 dataIndex: 'field2',1598 header: 'Field2'1599 }, {1600 header: 'Group1',1601 columns: [{1602 header: 'Group2',1603 columns: [{1604 dataIndex: 'field3',1605 header: 'Field3'1606 }, {1607 dataIndex: 'field4',1608 header: 'Field4'1609 }, {1610 dataIndex: 'field5',1611 header: 'Field5'1612 }, {1613 dataIndex: 'field6',1614 header: 'Field6'1615 }]1616 }]1617 }, {1618 dataIndex: 'field7',1619 header: 'Field7'1620 }, {1621 dataIndex: 'field8',1622 header: 'Field8'1623 }, {1624 dataIndex: 'field9',1625 header: 'Field9'1626 }];1627 function additionalSpec() {1628 // Group1 has been removed.1629 expect(groupHeader.ownerCt).toBe(null);1630 expect(groupHeader.rendered).toBe(false);1631 // Group2 is still around.1632 expect(subGroupHeader.ownerCt).not.toBe(null);1633 expect(subGroupHeader.rendered).toBe(true);1634 }1635 it('should remove the Group1 group header when Group2 is moved out of its grouping', function () {1636 runTest({1637 columns: columns,1638 order: '1,3,4,5,6,2,7,8,9',1639 sequence: [1640 ['subGroupHeader', 1, false]1641 ],1642 subGroupHeader: 11643 }, additionalSpec);1644 runTest({1645 columns: columns,1646 order: '1,2,7,8,3,4,5,6,9',1647 sequence: [1648 ['subGroupHeader', 7, true]1649 ],1650 subGroupHeader: 11651 }, additionalSpec);1652 });1653 it('should remove the Group1 group header when Group2 is dragged onto it, before position', function () {1654 runTest({1655 columns: columns,1656 order: '1,2,3,4,5,6,7,8,9',1657 sequence: [1658 ['subGroupHeader', 'groupHeader', false]1659 ],1660 groupHeader: 0,1661 subGroupHeader: 11662 }, additionalSpec);1663 });1664 it('should remove the Group1 group header when Group2 is dragged onto it, after position', function () {1665 runTest({1666 columns: columns,1667 order: '1,2,3,4,5,6,7,8,9',1668 sequence: [1669 ['subGroupHeader', 'groupHeader', true]1670 ],1671 subGroupHeader: 11672 }, additionalSpec);1673 });1674 });1675 describe('when the nested groups are aligned on either side', function () {1676 describe('aligned on left', function () {1677 var columns = [{1678 dataIndex: 'field1',1679 header: 'Field1'1680 }, {1681 dataIndex: 'field2',1682 header: 'Field2'1683 }, {1684 header: 'Group1',1685 columns: [{1686 header: 'Group2',1687 columns: [{1688 dataIndex: 'field3',1689 header: 'Field3'1690 }, {1691 dataIndex: 'field4',1692 header: 'Field4'1693 }, {1694 dataIndex: 'field5',1695 header: 'Field5'1696 }]1697 }, {1698 dataIndex: 'field6',1699 header: 'Field6'1700 }]1701 }, {1702 dataIndex: 'field7',1703 header: 'Field7'1704 }, {1705 dataIndex: 'field8',1706 header: 'Field8'1707 }, {1708 dataIndex: 'field9',1709 header: 'Field9'1710 }];1711 it('should work when the subgroupheader is dragged onto its ownerCt, before position', function () {1712 runTest({1713 columns: columns,1714 order: '1,2,3,4,5,6,7,8,9',1715 sequence: [1716 ['subGroupHeader', 'groupHeader', false]1717 ],1718 subGroupHeader: 11719 });1720 });1721 it('should work when the subgroupheader is dragged onto its ownerCt, after position', function () {1722 runTest({1723 columns: columns,1724 order: '1,2,6,3,4,5,7,8,9',1725 sequence: [1726 ['subGroupHeader', 'groupHeader', true]1727 ],1728 subGroupHeader: 11729 });1730 });1731 });1732 describe('aligned on right', function () {1733 var columns = [{1734 dataIndex: 'field1',1735 header: 'Field1'1736 }, {1737 dataIndex: 'field2',1738 header: 'Field2'1739 }, {1740 header: 'Group1',1741 columns: [{1742 dataIndex: 'field3',1743 header: 'Field3'1744 }, {1745 header: 'Group2',1746 columns: [{1747 dataIndex: 'field4',1748 header: 'Field4'1749 }, {1750 dataIndex: 'field5',1751 header: 'Field5'1752 }, {1753 dataIndex: 'field6',1754 header: 'Field6'1755 }]1756 }]1757 }, {1758 dataIndex: 'field7',1759 header: 'Field7'1760 }, {1761 dataIndex: 'field8',1762 header: 'Field8'1763 }, {1764 dataIndex: 'field9',1765 header: 'Field9'1766 }];1767 it('should work when the subgroupheader is dragged onto its ownerCt, before position', function () {1768 runTest({1769 columns: columns,1770 order: '1,2,4,5,6,3,7,8,9',1771 sequence: [1772 ['subGroupHeader', 'groupHeader', false]1773 ],1774 subGroupHeader: 11775 });1776 });1777 it('should work when the subgroupheader is dragged onto its ownerCt, after position', function () {1778 runTest({1779 columns: columns,1780 order: '1,2,3,4,5,6,7,8,9',1781 sequence: [1782 ['subGroupHeader', 'groupHeader', true]1783 ],1784 subGroupHeader: 11785 });1786 });1787 });1788 });1789 });1790 describe('when the headers are moved randomly', function () {1791 it("should work when the move position is 'before'", function () {1792 runTest({1793 columns: columns,1794 order: '6,1,9,2,3,7,4,5,8,10,11,12,13',1795 sequence: [1796 [5, 0, false],1797 [7, 9, false],1798 [6, 4, false],1799 [7, 2, false]1800 ]1801 });1802 });1803 it("should work when the move position is 'after'", function () {1804 runTest({1805 columns: columns,1806 order: '1,6,2,3,4,8,5,10,11,12,9,13,7',1807 sequence: [1808 [6, 12, true],1809 [6, 3, true],1810 [7, 10, true],1811 [6, 0, true]1812 ]1813 });1814 });1815 it("should work when the move position alternates between 'before' and 'after'", function () {1816 runTest({1817 columns: columns,1818 order: '1,2,9,3,6,4,7,5,8,10,11,12,13',1819 sequence: [1820 [6, 4, false],1821 [7, 9, false],1822 [7, 1, true],1823 [7, 3, true]1824 ]1825 });1826 });1827 });1828 });1829 describe('three nested groups', function () {1830 var columns = [{1831 dataIndex: 'field1',1832 header: 'Field1'1833 }, {1834 dataIndex: 'field2',1835 header: 'Field2'1836 }, {1837 header: 'Group1',1838 columns: [{1839 dataIndex: 'field3',1840 header: 'Field3'1841 }, {1842 dataIndex: 'field4',1843 header: 'Field4'1844 }, {1845 dataIndex: 'field5',1846 header: 'Field5'1847 }, {1848 header: 'Group2',1849 columns: [{1850 header: 'Group3',1851 columns: [{1852 dataIndex: 'field6',1853 header: 'Field6'1854 }, {1855 dataIndex: 'field7',1856 header: 'Field7'1857 }, {1858 dataIndex: 'field8',1859 header: 'Field8'1860 }, {1861 dataIndex: 'field9',1862 header: 'Field9'1863 }]1864 }, {1865 dataIndex: 'field10',1866 header: 'Field10'1867 }, {1868 dataIndex: 'field11',1869 header: 'Field11'1870 }, {1871 dataIndex: 'field12',1872 header: 'Field12'1873 }]1874 }, {1875 dataIndex: 'field13',1876 header: 'Field13'1877 }]1878 }, {1879 dataIndex: 'field14',1880 header: 'Field14'1881 }, {1882 dataIndex: 'field15',1883 header: 'Field15'1884 }, {1885 dataIndex: 'field16',1886 header: 'Field16'1887 }];1888 describe('dragging all subheaders out of Group3', function () {1889 describe('when the targetHeader is the Group3 groupHeader (so the drag is contiguous to Group3)', function () {1890 function additionalSpec() {1891 expect(subGroupHeader.ownerCt).toBe(null);1892 expect(subGroupHeader.rendered).toBe(false);1893 }1894 it('should work when the move position is before the target header', function () {1895 runTest({1896 columns: columns,1897 dropPosition: 'before',1898 order: '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16',1899 range: [5, 8],1900 subGroupHeader: 21901 }, additionalSpec);1902 });1903 it('should work when the move position is before the target header, in reverse', function () {1904 runTest({1905 columns: columns,1906 order: '1,2,3,4,5,9,8,7,6,10,11,12,13,14,15,16',1907 sequence: [1908 [8, 'subGroupHeader', false],1909 [8, 'subGroupHeader', false],1910 [8, 'subGroupHeader', false],1911 [8, 'subGroupHeader', false]1912 ],1913 subGroupHeader: 21914 }, additionalSpec);1915 });1916 it('should work when the move position is after the target header', function () {1917 runTest({1918 columns: columns,1919 dropPosition: 'right',1920 order: '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16',1921 range: [8, 5],1922 subGroupHeader: 21923 }, additionalSpec);1924 });1925 it('should work when the move position is after the target header, in reverse', function () {1926 runTest({1927 columns: columns,1928 dropPosition: 'right',1929 order: '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16',1930 range: [8, 5],1931 subGroupHeader: 21932 }, additionalSpec);1933 });1934 it("should work when the move position alternates between 'before' and 'after'", function () {1935 runTest({1936 columns: columns,1937 order: '1,2,3,4,5,7,9,6,8,10,11,12,13,14,15,16',1938 sequence: [1939 [6, 'subGroupHeader', false],1940 [7, 'subGroupHeader', true],1941 [6, 'subGroupHeader', true],1942 [6, 'subGroupHeader', false]1943 ],1944 subGroupHeader: 21945 }, additionalSpec);1946 });1947 });1948 describe('when the Group3 subheaders are dragged into Group2 (targetHeader is not Group3)', function () {1949 function additionalSpec() {1950 expect(subGroupHeader.ownerCt).toBe(null);1951 expect(subGroupHeader.rendered).toBe(false);1952 }1953 it('should work when the move position is after the last subheader in Group2', function () {1954 // Even though we're not using the subGroupHeader in the move sequence, we specify it b/c1955 // we're referencing it in the additionalSpec.1956 runTest({1957 columns: columns,1958 order: '1,2,3,4,5,10,11,12,6,7,8,9,13,14,15,16',1959 sequence: [1960 [5, 11, true],1961 [5, 11, true],1962 [5, 11, true],1963 [5, 11, true]1964 ],1965 subGroupHeader: 21966 }, additionalSpec);1967 });1968 it('should work when the move position is before the subheader directly after Group2', function () {1969 runTest({1970 columns: columns,1971 order: '1,2,3,4,5,10,11,12,9,8,7,6,13,14,15,16',1972 sequence: [1973 [5, 12, false],1974 [5, 11, false],1975 [5, 10, false],1976 [5, 9, false]1977 ],1978 subGroupHeader: 21979 });1980 });1981 });1982 describe('when the Group3 subheaders are dragged into Group1', function () {1983 function additionalSpec() {1984 expect(subGroupHeader.ownerCt).toBe(null);1985 expect(subGroupHeader.rendered).toBe(false);1986 }1987 it('should work when the move position is after the last subheader in Group1', function () {1988 // Even though we're not using the subGroupHeader in the move sequence, we specify it b/c1989 // we're referencing it in the additionalSpec.1990 runTest({1991 columns: columns,1992 order: '1,2,3,4,5,10,11,12,13,6,7,8,9,14,15,16',1993 sequence: [1994 [5, 12, true],1995 [5, 12, true],1996 [5, 12, true],1997 [5, 12, true]1998 ],1999 subGroupHeader: 22000 }, additionalSpec);2001 });2002 it('should work when the move position is after the last subheader in Group1, in reverse', function () {2003 runTest({2004 columns: columns,2005 dropPosition: 'after',2006 order: '1,2,3,4,5,10,11,12,13,6,7,8,9,14,15,16',2007 range: [8, 5]2008 });2009 });2010 it('should work when the move position is before the subheader directly after Group1', function () {2011 runTest({2012 columns: columns,2013 order: '1,2,3,4,5,10,11,12,9,8,7,6,13,14,15,16',2014 sequence: [2015 [5, 12, false],2016 [5, 11, false],2017 [5, 10, false],2018 [5, 9, false]2019 ],2020 subGroupHeader: 22021 }, additionalSpec);2022 });2023 it('should work when the move position is before the subheader directly after Group1, in reverse', function () {2024 runTest({2025 columns: columns,2026 order: '1,2,3,4,5,10,11,12,6,7,8,9,13,14,15,16',2027 sequence: [2028 [8, 12, false],2029 [7, 11, false],2030 [6, 10, false],2031 [5, 9, false]2032 ],2033 subGroupHeader: 22034 }, additionalSpec);2035 });2036 it('should work when the targetHeader is Group1 and the move position is before', function () {2037 runTest({2038 columns: columns,2039 order: '1,2,9,8,7,6,3,4,5,10,11,12,13,14,15,16',2040 sequence: [2041 [8, 'groupHeader', false],2042 [8, 'groupHeader', false],2043 [8, 'groupHeader', false],2044 [8, 'groupHeader', false]2045 ],2046 subGroupHeader: 22047 }, additionalSpec);2048 });2049 it('should work when the targetHeader is Group1 and the move position is after', function () {2050 runTest({2051 columns: columns,2052 order: '1,2,3,4,5,10,11,12,13,9,8,7,6,14,15,16',2053 sequence: [2054 [5, 'groupHeader', true],2055 [5, 'groupHeader', true],2056 [5, 'groupHeader', true],2057 [5, 'groupHeader', true]2058 ],2059 subGroupHeader: 22060 }, additionalSpec);2061 });2062 });2063 describe('when the Group3 subheaders are dragged into the root header container', function () {2064 // Note that not specifying a groupSubHeader with a range means that the groupHeader ref will2065 // be the first group found, which is Group1 and the one we want.2066 //2067 // Note that also we're testing that Group2 has been removed after the last subheader has been2068 // dragged out.2069 function additionalSpec() {2070 expect(subGroupHeader.rendered).toBe(false);2071 expect(subGroupHeader.ownerCt).toBe(null);2072 }2073 it('should work when the move position is before the first group header (Group1)', function () {2074 runTest({2075 columns: columns,2076 order: '1,2,6,7,8,9,3,4,5,10,11,12,13,14,15,16',2077 sequence: [2078 [5, 'groupHeader', false],2079 [6, 'groupHeader', false],2080 [7, 'groupHeader', false],2081 [8, 'groupHeader', false]2082 ],2083 subGroupHeader: 22084 }, additionalSpec);2085 });2086 it('should work when the move position is before the first group header (Group1), in reverse', function () {2087 // Note that specifying null in a sequence and not specifying a subGroupHeader config will2088 // have the value of groupHeader default to be the first group header found, which is2089 // Group1 and the one we want.2090 runTest({2091 columns: columns,2092 order: '1,2,9,8,7,6,3,4,5,10,11,12,13,14,15,16',2093 sequence: [2094 [8, 'groupHeader', false],2095 [8, 'groupHeader', false],2096 [8, 'groupHeader', false],2097 [8, 'groupHeader', false]2098 ],2099 subGroupHeader: 22100 }, additionalSpec);2101 });2102 it('should work when the move position is after the first group header (Group1)', function () {2103 runTest({2104 columns: columns,2105 order: '1,2,3,4,5,10,11,12,13,9,8,7,6,14,15,16',2106 sequence: [2107 [5, 'groupHeader', true],2108 [5, 'groupHeader', true],2109 [5, 'groupHeader', true],2110 [5, 'groupHeader', true]2111 ],2112 subGroupHeader: 22113 }, additionalSpec);2114 });2115 it('should work when the move position is after the first group header (Group1), in reverse', function () {2116 runTest({2117 columns: columns,2118 order: '1,2,3,4,5,10,11,12,13,6,7,8,9,14,15,16',2119 sequence: [2120 [8, 'groupHeader', true],2121 [7, 'groupHeader', true],2122 [6, 'groupHeader', true],2123 [5, 'groupHeader', true]2124 ],2125 subGroupHeader: 22126 }, additionalSpec);2127 });2128 it("should work when the move position alternates between 'before' and 'after'", function () {2129 runTest({2130 columns: columns,2131 order: '1,2,7,9,3,4,5,10,11,12,13,6,8,14,15,16',2132 sequence: [2133 [6, 'groupHeader', false],2134 [7, 'groupHeader', true],2135 [6, 'groupHeader', true],2136 [6, 'groupHeader', false]2137 ],2138 subGroupHeader: 22139 }, additionalSpec);2140 });2141 });2142 });2143 describe('moving the group header', function () {2144 describe('Group1', function () {2145 it('should move the group to the beginning of the root header container, before position', function () {2146 runTest({2147 columns: columns,2148 order: '3,4,5,6,7,8,9,10,11,12,13,1,2,14,15,16',2149 sequence: [2150 ['groupHeader', 0, false]2151 ]2152 });2153 });2154 it('should move the group to the beginning of the root header container, after position', function () {2155 runTest({2156 columns: columns,2157 order: '1,3,4,5,6,7,8,9,10,11,12,13,2,14,15,16',2158 sequence: [2159 ['groupHeader', 0, true]2160 ]2161 });2162 });2163 it('should move the group to the end of the root header container, before position', function () {2164 runTest({2165 columns: columns,2166 order: '1,2,14,15,3,4,5,6,7,8,9,10,11,12,13,16',2167 sequence: [2168 ['groupHeader', 15, false]2169 ]2170 });2171 });2172 it('should move the group to the end of the root header container, after position', function () {2173 runTest({2174 columns: columns,2175 order: '1,2,14,15,16,3,4,5,6,7,8,9,10,11,12,13',2176 sequence: [2177 ['groupHeader', 15, true]2178 ]2179 });2180 });2181 });2182 describe('Group2', function () {2183 it('should move the group to the beginning of the root header container, before position', function () {2184 runTest({2185 columns: columns,2186 order: '6,7,8,9,10,11,12,1,2,3,4,5,13,14,15,16',2187 sequence: [2188 ['subGroupHeader', 0, false]2189 ],2190 subGroupHeader: 12191 });2192 });2193 it('should move the group to the beginning of the root header container, after position', function () {2194 runTest({2195 columns: columns,2196 order: '1,6,7,8,9,10,11,12,2,3,4,5,13,14,15,16',2197 sequence: [2198 ['subGroupHeader', 0, true]2199 ],2200 subGroupHeader: 12201 });2202 });2203 it('should move the group to the end of the root header container, before position', function () {2204 runTest({2205 columns: columns,2206 order: '1,2,3,4,5,13,14,15,6,7,8,9,10,11,12,16',2207 sequence: [2208 ['subGroupHeader', 15, false]2209 ],2210 subGroupHeader: 12211 });2212 });2213 it('should move the group to the end of the root header container, after position', function () {2214 runTest({2215 columns: columns,2216 order: '1,2,3,4,5,13,14,15,16,6,7,8,9,10,11,12',2217 sequence: [2218 ['subGroupHeader', 15, true]2219 ],2220 subGroupHeader: 12221 });2222 });2223 it('should move the group to the beginning of Group1', function () {2224 runTest({2225 columns: columns,2226 order: '1,2,6,7,8,9,10,11,12,3,4,5,13,14,15,16',2227 sequence: [2228 ['subGroupHeader', 2, false]2229 ],2230 subGroupHeader: 12231 });2232 });2233 it('should move the group to the end of Group1', function () {2234 runTest({2235 columns: columns,2236 order: '1,2,3,4,5,13,6,7,8,9,10,11,12,14,15,16',2237 sequence: [2238 ['subGroupHeader', 12, true]2239 ],2240 subGroupHeader: 12241 });2242 });2243 });2244 describe('Group3', function () {2245 it('should move the group to the beginning of the root header container, before position', function () {2246 runTest({2247 columns: columns,2248 order: '6,7,8,9,1,2,3,4,5,10,11,12,13,14,15,16',2249 sequence: [2250 ['subGroupHeader', 0, false]2251 ],2252 subGroupHeader: 22253 });2254 });2255 it('should move the group to the beginning of the root header container, after position', function () {2256 runTest({2257 columns: columns,2258 order: '1,6,7,8,9,2,3,4,5,10,11,12,13,14,15,16',2259 sequence: [2260 ['subGroupHeader', 0, true]2261 ],2262 subGroupHeader: 22263 });2264 });2265 it('should move the group to the end of the root header container, before position', function () {2266 runTest({2267 columns: columns,2268 order: '1,2,3,4,5,10,11,12,13,14,15,6,7,8,9,16',2269 sequence: [2270 ['subGroupHeader', 15, false]2271 ],2272 subGroupHeader: 22273 });2274 });2275 it('should move the group to the end of the root header container, after position', function () {2276 runTest({2277 columns: columns,2278 order: '1,2,3,4,5,10,11,12,13,14,15,16,6,7,8,9',2279 sequence: [2280 ['subGroupHeader', 15, true]2281 ],2282 subGroupHeader: 22283 });2284 });2285 it('should move the group to the beginning of Group1', function () {2286 runTest({2287 columns: columns,2288 order: '1,2,6,7,8,9,3,4,5,10,11,12,13,14,15,16',2289 sequence: [2290 ['subGroupHeader', 2, false]2291 ],2292 subGroupHeader: 22293 });2294 });2295 it('should move the group to the end of Group1', function () {2296 runTest({2297 columns: columns,2298 order: '1,2,3,4,5,10,11,12,13,6,7,8,9,14,15,16',2299 sequence: [2300 ['subGroupHeader', 12, true]2301 ],2302 subGroupHeader: 22303 });2304 });2305 it('should move the group to the beginning of Group2', function () {2306 runTest({2307 columns: columns,2308 order: '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16',2309 sequence: [2310 ['subGroupHeader', 'groupHeader', false]2311 ],2312 groupHeader: 1,2313 subGroupHeader: 22314 });2315 });2316 it('should move the group to the end of Group2', function () {2317 runTest({2318 columns: columns,2319 order: '1,2,3,4,5,10,11,12,6,7,8,9,13,14,15,16',2320 sequence: [2321 ['subGroupHeader', 'groupHeader', true]2322 ],2323 groupHeader: 1,2324 subGroupHeader: 22325 });2326 });2327 });2328 describe('when the nested groups are stacked directly on top of each other', function () {2329 var columns = [{2330 dataIndex: 'field1',2331 header: 'Field1'2332 }, {2333 dataIndex: 'field2',2334 header: 'Field2'2335 }, {2336 header: 'Group1',2337 columns: [{2338 header: 'Group2',2339 columns: [{2340 header: 'Group3',2341 columns: [{2342 dataIndex: 'field3',2343 header: 'Field3'2344 }, {2345 dataIndex: 'field4',2346 header: 'Field4'2347 }, {2348 dataIndex: 'field5',2349 header: 'Field5'2350 }, {2351 dataIndex: 'field6',2352 header: 'Field6'2353 }]2354 }]2355 }]2356 }, {2357 dataIndex: 'field7',2358 header: 'Field7'2359 }, {2360 dataIndex: 'field8',2361 header: 'Field8'2362 }, {2363 dataIndex: 'field9',2364 header: 'Field9'2365 }];2366 function additionalSpec() {2367 // Group1 has been removed.2368 expect(groupHeader.ownerCt).toBe(null);2369 expect(groupHeader.rendered).toBe(false);2370 // Group2 is still around.2371 expect(subGroupHeader.ownerCt).not.toBe(null);2372 expect(subGroupHeader.rendered).toBe(true);2373 }2374 function nestedSpec() {2375 expect(groupHeader.ownerCt).toBe(null);2376 expect(groupHeader.rendered).toBe(false);2377 expect(headerCt.down('[text=Group1]')).toBe(null);2378 }2379 it('should remove the Group1 group header when Group2 is moved out of its grouping', function () {2380 runTest({2381 columns: columns,2382 order: '1,3,4,5,6,2,7,8,9',2383 sequence: [2384 ['subGroupHeader', 1, false]2385 ],2386 subGroupHeader: 12387 }, additionalSpec);2388 runTest({2389 columns: columns,2390 order: '1,2,7,8,3,4,5,6,9',2391 sequence: [2392 ['subGroupHeader', 7, true]2393 ],2394 subGroupHeader: 12395 }, additionalSpec);2396 });2397 it('should remove both the Group1 and Group2 group headers when Group3 is moved out of its grouping', function () {2398 runTest({2399 columns: columns,2400 order: '1,3,4,5,6,2,7,8,9',2401 sequence: [2402 ['subGroupHeader', 1, false]2403 ],2404 subGroupHeader: 22405 }, nestedSpec);2406 runTest({2407 columns: columns,2408 order: '1,2,7,8,3,4,5,6,9',2409 sequence: [2410 ['subGroupHeader', 7, true]2411 ],2412 subGroupHeader: 22413 }, nestedSpec);2414 });2415 it('should remove the Group1 group header when Group2 is dragged onto it, before position', function () {2416 runTest({2417 columns: columns,2418 order: '1,2,3,4,5,6,7,8,9',2419 sequence: [2420 ['subGroupHeader', 'groupHeader', false]2421 ],2422 subGroupHeader: 12423 }, additionalSpec);2424 });2425 it('should remove the Group1 group header when Group2 is dragged onto it, after position', function () {2426 runTest({2427 columns: columns,2428 order: '1,2,3,4,5,6,7,8,9',2429 sequence: [2430 ['subGroupHeader', 'groupHeader', true]2431 ],2432 subGroupHeader: 12433 }, additionalSpec);2434 });2435 it('should remove both the Group1 and Group2 group headers when Group3 is dragged onto Group1, before position', function () {2436 runTest({2437 columns: columns,2438 order: '1,2,3,4,5,6,7,8,9',2439 sequence: [2440 ['subGroupHeader', 'groupHeader', false]2441 ],2442 subGroupHeader: 22443 }, nestedSpec);2444 });2445 it('should remove both the Group1 and Group2 group headers when Group3 is dragged onto Group1 , after position', function () {2446 runTest({2447 columns: columns,2448 order: '1,2,3,4,5,6,7,8,9',2449 sequence: [2450 ['subGroupHeader', 'groupHeader', true]2451 ],2452 subGroupHeader: 22453 }, nestedSpec);2454 });2455 });2456 describe('when the nested groups are aligned on either side', function () {2457 describe('aligned on left', function () {2458 var columns = [{2459 dataIndex: 'field1',2460 header: 'Field1'2461 }, {2462 dataIndex: 'field2',2463 header: 'Field2'2464 }, {2465 header: 'Group1',2466 columns: [{2467 header: 'Group2',2468 columns: [{2469 header: 'Group3',2470 columns: [{2471 dataIndex: 'field3',2472 header: 'Field3'2473 }, {2474 dataIndex: 'field4',2475 header: 'Field4'2476 }, {2477 dataIndex: 'field5',2478 header: 'Field5'2479 }]2480 }]2481 }, {2482 dataIndex: 'field6',2483 header: 'Field6'2484 }]2485 }, {2486 dataIndex: 'field7',2487 header: 'Field7'2488 }, {2489 dataIndex: 'field8',2490 header: 'Field8'2491 }, {2492 dataIndex: 'field9',2493 header: 'Field9'2494 }];2495 describe('Group2 and Group3 are aligned left with a header to the right', function () {2496 // +-----------------------------------+2497 // | Group 1 |2498 // |-----------------------------------|2499 // | Group2 | |2500 // other |--------------------------| | other2501 // headers | Group3 | Field6 | headers2502 // |--------------------------| |2503 // | Field3 | Field4 | Field5 | |2504 // |===================================|2505 // | view |2506 // +-----------------------------------+2507 function test1() {2508 // Expect that Group2 has been removed and that Group3 is still a child of Group1.2509 expect(groupHeader.ownerCt).toBe(null);2510 expect(groupHeader.rendered).toBe(false);2511 expect(subGroupHeader.ownerCt).toBe(headerCt.down('[text=Group1]'));2512 }2513 function test2() {2514 // Expect that Group2 has been removed and that Group3 is a sibling of Group1.2515 expect(headerCt.down('[text=Group2]')).toBe(null);2516 expect(subGroupHeader.ownerCt).toBe(groupHeader.ownerCt);2517 }2518 function test3() {2519 // Expect that Group2 is still the parent of Group3 and that Group2 and Group1 are siblings.2520 expect(headerCt.down('[text=Group3]').ownerCt).toBe(subGroupHeader);2521 expect(subGroupHeader.ownerCt).toBe(groupHeader.ownerCt);2522 }2523 it('should work when Group3 is dragged onto Group2, before position', function () {2524 runTest({2525 columns: columns,2526 order: '1,2,3,4,5,6,7,8,9',2527 sequence: [2528 ['subGroupHeader', 'groupHeader', false]2529 ],2530 groupHeader: 1,2531 subGroupHeader: 22532 }, test1);2533 });2534 it('should work when Group3 is dragged onto Group2, after position', function () {2535 runTest({2536 columns: columns,2537 order: '1,2,3,4,5,6,7,8,9',2538 sequence: [2539 ['subGroupHeader', 'groupHeader', true]2540 ],2541 groupHeader: 1,2542 subGroupHeader: 22543 }, test1);2544 });2545 it('should work when Group3 is dragged onto Group1, before position', function () {2546 runTest({2547 columns: columns,2548 order: '1,2,3,4,5,6,7,8,9',2549 sequence: [2550 ['subGroupHeader', 'groupHeader', false]2551 ],2552 subGroupHeader: 22553 }, test2);2554 });2555 it('should work when Group3 is dragged onto Group1, after position', function () {2556 runTest({2557 columns: columns,2558 order: '1,2,6,3,4,5,7,8,9',2559 sequence: [2560 ['subGroupHeader', 'groupHeader', true]2561 ],2562 subGroupHeader: 22563 }, test2);2564 });2565 it('should work when Group2 is dragged onto Group1, before position', function () {2566 runTest({2567 columns: columns,2568 order: '1,2,3,4,5,6,7,8,9',2569 sequence: [2570 ['subGroupHeader', 'groupHeader', false]2571 ],2572 subGroupHeader: 12573 }, test3);2574 });2575 it('should work when Group2 is dragged onto Group1, after position', function () {2576 runTest({2577 columns: columns,2578 order: '1,2,6,3,4,5,7,8,9',2579 sequence: [2580 ['subGroupHeader', 'groupHeader', true]2581 ],2582 subGroupHeader: 12583 }, test3);2584 });2585 });2586 });2587 describe('aligned on right', function () {2588 var columns = [{2589 dataIndex: 'field1',2590 header: 'Field1'2591 }, {2592 dataIndex: 'field2',2593 header: 'Field2'2594 }, {2595 header: 'Group1',2596 columns: [{2597 dataIndex: 'field3',2598 header: 'Field3'2599 }, {2600 header: 'Group2',2601 columns: [{2602 header: 'Group3',2603 columns: [{2604 dataIndex: 'field4',2605 header: 'Field4'2606 }, {2607 dataIndex: 'field5',2608 header: 'Field5'2609 }, {2610 dataIndex: 'field6',2611 header: 'Field6'2612 }]2613 }]2614 }]2615 }, {2616 dataIndex: 'field7',2617 header: 'Field7'2618 }, {2619 dataIndex: 'field8',2620 header: 'Field8'2621 }, {2622 dataIndex: 'field9',2623 header: 'Field9'2624 }];2625 describe('Group2 and Group3 are aligned right with a header to the left', function () {2626 // +-----------------------------------+2627 // | Group 1 |2628 // |-----------------------------------|2629 // | | Group2 |2630 // other | |--------------------------| other2631 // headers | Field3 | Group3 | headers2632 // | |--------------------------|2633 // | | Field4 | Field5 | Field6 |2634 // |===================================|2635 // | view |2636 // +-----------------------------------+2637 function test1() {2638 // Expect that Group2 has been removed and that Group3 is still a child of Group1.2639 expect(groupHeader.ownerCt).toBe(null);2640 expect(groupHeader.rendered).toBe(false);2641 expect(subGroupHeader.ownerCt).toBe(headerCt.down('[text=Group1]'));2642 }2643 function test2() {2644 // Expect that Group2 has been removed and that Group3 is a sibling of Group1.2645 expect(headerCt.down('[text=Group2]')).toBe(null);2646 expect(subGroupHeader.ownerCt).toBe(groupHeader.ownerCt);2647 }2648 function test3() {2649 // Expect that Group2 is still the parent of Group3 and that Group2 and Group1 are siblings.2650 expect(headerCt.down('[text=Group3]').ownerCt).toBe(subGroupHeader);2651 expect(subGroupHeader.ownerCt).toBe(groupHeader.ownerCt);2652 }2653 it('should work when Group3 is dragged onto Group2, before position', function () {2654 runTest({2655 columns: columns,2656 order: '1,2,3,4,5,6,7,8,9',2657 sequence: [2658 ['subGroupHeader', 'groupHeader', false]2659 ],2660 groupHeader: 1,2661 subGroupHeader: 22662 }, test1);2663 });2664 it('should work when Group3 is dragged onto Group2, after position', function () {2665 runTest({2666 columns: columns,2667 order: '1,2,3,4,5,6,7,8,9',2668 sequence: [2669 ['subGroupHeader', 'groupHeader', true]2670 ],2671 groupHeader: 1,2672 subGroupHeader: 22673 }, test1);2674 });2675 it('should work when Group3 is dragged onto Group1, before position', function () {2676 runTest({2677 columns: columns,2678 order: '1,2,4,5,6,3,7,8,9',2679 sequence: [2680 ['subGroupHeader', 'groupHeader', false]2681 ],2682 subGroupHeader: 22683 }, test2);2684 });2685 it('should work when Group3 is dragged onto Group1, after position', function () {2686 runTest({2687 columns: columns,2688 order: '1,2,3,4,5,6,7,8,9',2689 sequence: [2690 ['subGroupHeader', 'groupHeader', true]2691 ],2692 subGroupHeader: 22693 }, test2);2694 });2695 it('should work when Group2 is dragged onto Group1, before position', function () {2696 runTest({2697 columns: columns,2698 order: '1,2,4,5,6,3,7,8,9',2699 sequence: [2700 ['subGroupHeader', 'groupHeader', false]2701 ],2702 subGroupHeader: 12703 }, test3);2704 });2705 it('should work when Group2 is dragged onto Group1, after position', function () {2706 runTest({2707 columns: columns,2708 order: '1,2,3,4,5,6,7,8,9',2709 sequence: [2710 ['subGroupHeader', 'groupHeader', true]2711 ],2712 subGroupHeader: 12713 }, test3);2714 });2715 });2716 });2717 });2718 });2719 });2720 describe('four nested groups', function () {2721 describe('when the nested groups are stacked directly on top of each other', function () {2722 var columns = [{2723 dataIndex: 'field1',2724 header: 'Field1'2725 }, {2726 dataIndex: 'field2',2727 header: 'Field2'2728 }, {2729 header: 'Group1',2730 columns: [{2731 header: 'Group2',2732 columns: [{2733 header: 'Group3',2734 columns: [{2735 header: 'Group4',2736 columns: [{2737 dataIndex: 'field3',2738 header: 'Field3'2739 }, {2740 dataIndex: 'field4',2741 header: 'Field4'2742 }, {2743 dataIndex: 'field5',2744 header: 'Field5'2745 }, {2746 dataIndex: 'field6',2747 header: 'Field6'2748 }]2749 }]2750 }]2751 }]2752 }, {2753 dataIndex: 'field7',2754 header: 'Field7'2755 }, {2756 dataIndex: 'field8',2757 header: 'Field8'2758 }, {2759 dataIndex: 'field9',2760 header: 'Field9'2761 }];2762 function additionalSpec() {2763 // Group1 has been removed.2764 expect(groupHeader.ownerCt).toBe(null);2765 expect(groupHeader.rendered).toBe(false);2766 // All the other groups are still around.2767 expect(subGroupHeader.rendered).toBe(true);2768 expect(headerCt.down('[text=Group3]').rendered).toBe(true);2769 expect(headerCt.down('[text=Group4]').rendered).toBe(true);2770 }2771 function nestedSpec() {2772 // Groups 1 and 2 have been removed.2773 expect(groupHeader.ownerCt).toBe(null);2774 expect(groupHeader.rendered).toBe(false);2775 expect(headerCt.down('[text=Group2]')).toBe(null);2776 // All the other groups are still around.2777 expect(headerCt.down('[text=Group3]').rendered).toBe(true);2778 expect(headerCt.down('[text=Group4]').rendered).toBe(true);2779 }2780 function nestedSpec2() {2781 // Groups 1, 2 and 3 have been removed.2782 expect(groupHeader.ownerCt).toBe(null);2783 expect(groupHeader.rendered).toBe(false);2784 expect(headerCt.down('[text=Group2]')).toBe(null);2785 expect(headerCt.down('[text=Group3]')).toBe(null);2786 expect(headerCt.down('[text=Group4]').rendered).toBe(true);2787 }2788 function nestedSpec3() {2789 expect(groupHeader.ownerCt).toBe(null);2790 expect(groupHeader.rendered).toBe(false);2791 expect(headerCt.down('[text=Group2]')).toBe(null);2792 expect(headerCt.down('[text=Group3]').rendered).toBe(true);2793 expect(headerCt.down('[text=Group4]').rendered).toBe(true);2794 }2795 describe('when its moved out of its stacked grouping', function () {2796 it('should remove the Group1 group header when Group2 is moved out of its grouping', function () {2797 runTest({2798 columns: columns,2799 order: '3,4,5,6,1,2,7,8,9',2800 sequence: [2801 ['subGroupHeader', 0, false]2802 ],2803 subGroupHeader: 12804 }, additionalSpec);2805 runTest({2806 columns: columns,2807 order: '1,2,7,8,3,4,5,6,9',2808 sequence: [2809 ['subGroupHeader', 7, true]2810 ],2811 subGroupHeader: 12812 }, additionalSpec);2813 });2814 it('should remove both the Group1 and Group2 group headers when Group3 is moved out of its grouping', function () {2815 runTest({2816 columns: columns,2817 order: '1,3,4,5,6,2,7,8,9',2818 sequence: [2819 ['subGroupHeader', 0, true]2820 ],2821 subGroupHeader: 22822 }, nestedSpec);2823 runTest({2824 columns: columns,2825 order: '1,2,7,3,4,5,6,8,9',2826 sequence: [2827 ['subGroupHeader', 7, false]2828 ],2829 subGroupHeader: 22830 }, nestedSpec);2831 });2832 it('should remove the Group1, Group2 and Group3 group headers when Group4 is moved out of its grouping', function () {2833 runTest({2834 columns: columns,2835 order: '1,3,4,5,6,2,7,8,9',2836 sequence: [2837 ['subGroupHeader', 1, false]2838 ],2839 subGroupHeader: 32840 }, nestedSpec2);2841 runTest({2842 columns: columns,2843 order: '1,2,7,3,4,5,6,8,9',2844 sequence: [2845 ['subGroupHeader', 6, true]2846 ],2847 subGroupHeader: 32848 }, nestedSpec2);2849 });2850 });2851 describe('when the targetHeader is an ancestor group within the stacked grouping', function () {2852 describe('when Group1 is the targetHeader', function () {2853 it('should remove the Group1 group header when Group2 is dragged onto it, before position', function () {2854 runTest({2855 columns: columns,2856 order: '1,2,3,4,5,6,7,8,9',2857 sequence: [2858 ['subGroupHeader', 'groupHeader', false]2859 ],2860 subGroupHeader: 12861 }, additionalSpec);2862 });2863 it('should remove the Group1 group header when Group2 is dragged onto it, after position', function () {2864 runTest({2865 columns: columns,2866 order: '1,2,3,4,5,6,7,8,9',2867 sequence: [2868 ['subGroupHeader', 'groupHeader', true]2869 ],2870 subGroupHeader: 12871 }, additionalSpec);2872 });2873 it('should remove both the Group1 and Group2 group headers when Group3 is dragged onto it, before position', function () {2874 runTest({2875 columns: columns,2876 order: '1,2,3,4,5,6,7,8,9',2877 sequence: [2878 ['subGroupHeader', 'groupHeader', false]2879 ],2880 subGroupHeader: 22881 }, nestedSpec);2882 });2883 it('should remove both the Group1 and Group2 group headers when Group3 is dragged onto it, after position', function () {2884 runTest({2885 columns: columns,2886 order: '1,2,3,4,5,6,7,8,9',2887 sequence: [2888 ['subGroupHeader', 'groupHeader', true]2889 ],2890 subGroupHeader: 22891 }, nestedSpec);2892 });2893 it('should remove the Group1, Group2 and Group3 group headers when Group4 is dragged onto it, before position', function () {2894 runTest({2895 columns: columns,2896 order: '1,2,3,4,5,6,7,8,9',2897 sequence: [2898 ['subGroupHeader', 'groupHeader', false]2899 ],2900 subGroupHeader: 32901 }, nestedSpec2);2902 });2903 it('should remove the Group1, Group2 and Group3 group headers when Group4 is dragged onto it, after position', function () {2904 runTest({2905 columns: columns,2906 order: '1,2,3,4,5,6,7,8,9',2907 sequence: [2908 ['subGroupHeader', 'groupHeader', true]2909 ],2910 subGroupHeader: 32911 }, nestedSpec2);2912 });2913 });2914 describe('when Group2 is the targetHeader', function () {2915 it('should remove the Group2 group header when Group 3 is dragged onto it, before position', function () {2916 runTest({2917 columns: columns,2918 order: '1,2,3,4,5,6,7,8,9',2919 sequence: [2920 ['subGroupHeader', 'groupHeader', false]2921 ],2922 groupHeader: 1,2923 subGroupHeader: 22924 }, additionalSpec);2925 });2926 it('should remove the Group2 group header when Group 3 is dragged onto it, after position', function () {2927 runTest({2928 columns: columns,2929 order: '1,2,3,4,5,6,7,8,9',2930 sequence: [2931 ['subGroupHeader', 'groupHeader', true]2932 ],2933 groupHeader: 1,2934 subGroupHeader: 22935 }, additionalSpec);2936 });2937 it('should remove the Group2 and Group3 group headers when Group4 is dragged onto it, before position', function () {2938 runTest({2939 columns: columns,2940 order: '1,2,3,4,5,6,7,8,9',2941 sequence: [2942 ['subGroupHeader', 'groupHeader', false]2943 ],2944 groupHeader: 1,2945 subGroupHeader: 32946 }, nestedSpec2);2947 });2948 it('should remove the Group1, Group2 and Group3 group headers when Group4 is dragged onto it, after position', function () {2949 runTest({2950 columns: columns,2951 order: '1,2,3,4,5,6,7,8,9',2952 sequence: [2953 ['subGroupHeader', 'groupHeader', true]2954 ],2955 groupHeader: 1,2956 subGroupHeader: 32957 }, nestedSpec2);2958 });2959 });2960 describe('when Group3 is the targetHeader', function () {2961 function additionalSpec() {2962 expect(groupHeader.rendered).toBe(false);2963 expect(subGroupHeader.rendered).toBe(true);2964 expect(headerCt.down('[text=Group1]').rendered).toBe(true);2965 expect(headerCt.down('[text=Group2]').rendered).toBe(true);2966 }2967 it('should remove the Group3 group header when Group4 is dragged onto it, before position', function () {2968 runTest({2969 columns: columns,2970 order: '1,2,3,4,5,6,7,8,9',2971 sequence: [2972 ['subGroupHeader', 'groupHeader', false]2973 ],2974 groupHeader: 2,2975 subGroupHeader: 32976 }, additionalSpec);2977 });2978 it('should remove the Group3 group header when Group4 is dragged onto it, after position', function () {2979 runTest({2980 columns: columns,2981 order: '1,2,3,4,5,6,7,8,9',2982 sequence: [2983 ['subGroupHeader', 'groupHeader', true]2984 ],2985 groupHeader: 2,2986 subGroupHeader: 32987 }, additionalSpec);2988 });2989 });2990 });2991 });2992 });2993 describe('locked grids', function () {2994 describe('one nested group', function () {2995 var columns = [{2996 dataIndex: 'field1',2997 header: 'Field1',2998 locked: true2999 }, {3000 dataIndex: 'field2',3001 header: 'Field2',3002 locked: true3003 }, {3004 header: 'Group1',3005 locked: true,3006 columns: [{3007 dataIndex: 'field3',3008 header: 'Field3'3009 }, {3010 dataIndex: 'field4',3011 header: 'Field4'3012 }, {3013 dataIndex: 'field5',3014 header: 'Field5'3015 }, {3016 dataIndex: 'field6',3017 header: 'Field6'3018 }]3019 }, {3020 dataIndex: 'field7',3021 header: 'Field7',3022 locked: true3023 }, {3024 dataIndex: 'field8',3025 header: 'Field8',3026 locked: true3027 }, {3028 dataIndex: 'field9',3029 header: 'Field9'3030 }, {3031 header: 'Group2',3032 columns: [{3033 dataIndex: 'field10',3034 header: 'Field10'3035 }, {3036 dataIndex: 'field11',3037 header: 'Field11'3038 }, {3039 dataIndex: 'field12',3040 header: 'Field12'3041 }, {3042 dataIndex: 'field13',3043 header: 'Field13'3044 }]3045 }, {3046 dataIndex: 'field14',3047 header: 'Field14'3048 }, {3049 dataIndex: 'field15',3050 header: 'Field15'3051 }];3052 // Note to get a group other than the first one, use the groupHeader cfg. This will always do:3053 //3054 // grid.headerCt.query('[isGroupHeader]')[groupHeader];3055 //3056 describe('moving the group from one locked side to another', function () {3057 it('should work moving from locked to normal', function () {3058 // Note you don't have to specify a groupHeader here since it will default to the first one.3059 runTest({3060 columns: columns,3061 locked: true,3062 order: '1,2,7,8,9,10,11,12,13,3,4,5,6,14,15',3063 sequence: [3064 ['groupHeader', 13, false]3065 ]3066 });3067 });3068 it('should work moving from normal to locked', function () {3069 runTest({3070 columns: columns,3071 locked: true,3072 order: '1,10,11,12,13,2,3,4,5,6,7,8,9,14,15',3073 groupHeader: 1,3074 sequence: [3075 ['groupHeader', 0, true]3076 ]3077 });3078 });3079 });3080 describe('moving the group from one locked side to another into another group', function () {3081 describe('moving from locked to normal', function () {3082 function additionalSpec() {3083 // TODO: better to use refs here if possible.3084 // Group2 should be the owner of Group1.3085 expect(!!headerCt.down('[text=Group2]').down('[text=Group1]')).toBe(true);3086 }3087 it('should work moving before the first nested header in the target group', function () {3088 runTest({3089 columns: columns,3090 locked: true,3091 order: '1,2,7,8,9,3,4,5,6,10,11,12,13,14,15',3092 sequence: [3093 ['groupHeader', 9, false]3094 ]3095 });3096 });3097 it('should work moving after the last nested header in the target group', function () {3098 runTest({3099 columns: columns,3100 locked: true,3101 order: '1,2,7,8,9,10,11,12,13,3,4,5,6,14,15',3102 sequence: [3103 ['groupHeader', 12, true]3104 ]3105 });3106 });3107 it('should work moving into the middle of the target group', function () {3108 runTest({3109 columns: columns,3110 locked: true,3111 order: '1,2,7,8,9,10,11,3,4,5,6,12,13,14,15',3112 sequence: [3113 ['groupHeader', 10, true]3114 ]3115 }, additionalSpec);3116 runTest({3117 columns: columns,3118 locked: true,3119 order: '1,2,7,8,9,10,11,12,3,4,5,6,13,14,15',3120 sequence: [3121 ['groupHeader', 12, false]3122 ]3123 }, additionalSpec);3124 });3125 });3126 describe('moving from normal to locked', function () {3127 function additionalSpec() {3128 // TODO: better to use refs here if possible.3129 // Group1 should be the owner of Group2.3130 expect(!!headerCt.down('[text=Group1]').down('[text=Group2]')).toBe(true);3131 }3132 it('should work moving before the first nested header in the target group', function () {3133 runTest({3134 columns: columns,3135 locked: true,3136 order: '1,2,10,11,12,13,3,4,5,6,7,8,9,14,15',3137 sequence: [3138 ['subGroupHeader', 2, false]3139 ],3140 subGroupHeader: 13141 });3142 });3143 it('should work moving after the last nested header in the target group', function () {3144 runTest({3145 columns: columns,3146 locked: true,3147 order: '1,2,3,4,5,6,10,11,12,13,7,8,9,14,15',3148 sequence: [3149 ['subGroupHeader', 5, true]3150 ],3151 subGroupHeader: 13152 });3153 });3154 it('should work moving into the middle of the target group', function () {3155 runTest({3156 columns: columns,3157 locked: true,3158 order: '1,2,3,4,10,11,12,13,5,6,7,8,9,14,15',3159 sequence: [3160 ['subGroupHeader', 3, true]3161 ],3162 subGroupHeader: 13163 }, additionalSpec);3164 runTest({3165 columns: columns,3166 locked: true,3167 order: '1,2,3,4,10,11,12,13,5,6,7,8,9,14,15',3168 sequence: [3169 ['subGroupHeader', 4, false]3170 ],3171 subGroupHeader: 13172 }, additionalSpec);3173 });3174 });3175 });3176 });3177 describe('two nested groups', function () {3178 var columns = [{3179 dataIndex: 'field1',3180 header: 'Field1',3181 locked: true3182 }, {3183 dataIndex: 'field2',3184 header: 'Field2',3185 locked: true3186 }, {3187 header: 'Group1',3188 locked: true,3189 columns: [{3190 dataIndex: 'field3',3191 header: 'Field3'3192 }, {3193 header: 'Group3',3194 columns: [{3195 dataIndex: 'field4',3196 header: 'Field4'3197 }, {3198 dataIndex: 'field5',3199 header: 'Field5'3200 }, {3201 dataIndex: 'field6',3202 header: 'Field6'3203 }]3204 }, {3205 dataIndex: 'field7',3206 header: 'Field7'3207 }, {3208 dataIndex: 'field8',3209 header: 'Field8'3210 }]3211 }, {3212 dataIndex: 'field9',3213 header: 'Field9',3214 locked: true3215 }, {3216 dataIndex: 'field10',3217 header: 'Field10',3218 locked: true3219 }, {3220 dataIndex: 'field11',3221 header: 'Field11'3222 }, {3223 header: 'Group2',3224 columns: [{3225 header: 'Group4',3226 columns: [{3227 dataIndex: 'field12',3228 header: 'Field12'3229 }, {3230 dataIndex: 'field13',3231 header: 'Field13'3232 }]3233 }, {3234 dataIndex: 'field14',3235 header: 'Field14'3236 }, {3237 dataIndex: 'field15',3238 header: 'Field15'3239 }, {3240 dataIndex: 'field16',3241 header: 'Field16'3242 }]3243 }, {3244 dataIndex: 'field17',3245 header: 'Field17'3246 }, {3247 dataIndex: 'field18',3248 header: 'Field18'3249 }];3250 // Note to get a group other than the first one, use the groupHeader cfg. This will always do:3251 //3252 // grid.headerCt.query('[isGroupHeader]')[groupHeader];3253 //3254 describe('moving the group from one locked side to another', function () {3255 it('should work moving from locked to normal, Group1 (1st nested)', function () {3256 runTest({3257 columns: columns,3258 locked: true,3259 order: '1,2,9,10,11,12,13,14,15,16,3,4,5,6,7,8,17,18',3260 sequence: [3261 ['groupHeader', 16, false]3262 ]3263 });3264 });3265 it('should work moving from locked to normal, Group3 (2nd nested)', function () {3266 runTest({3267 columns: columns,3268 groupHeader: 1,3269 locked: true,3270 order: '1,2,3,7,8,9,10,11,12,13,14,15,16,17,18,4,5,6',3271 sequence: [3272 ['groupHeader', 17, true]3273 ]3274 }, function () {3275 // Check Group3 has indeed been moved out of its nesting.3276 expect(headerCt.down('[text=Group3]').ownerCt).not.toBe(headerCt.down('[text=Group1]'));3277 });3278 });3279 it('should work moving from normal to locked, Group1 (1st nested)', function () {3280 runTest({3281 columns: columns,3282 groupHeader: 2,3283 locked: true,3284 order: '1,12,13,14,15,16,2,3,4,5,6,7,8,9,10,11,17,18',3285 sequence: [3286 ['groupHeader', 1, false]3287 ]3288 });3289 });3290 it('should work moving from normal to locked, Group4 (2nd nested)', function () {3291 runTest({3292 columns: columns,3293 groupHeader: 3,3294 locked: true,3295 order: '1,2,3,4,5,6,7,8,9,10,12,13,11,14,15,16,17,18',3296 sequence: [3297 ['groupHeader', 9, true]3298 ]3299 }, function () {3300 // Check Group4 has indeed been moved out of its nesting.3301 expect(headerCt.down('[text=Group4]').ownerCt).not.toBe(headerCt.down('[text=Group2]'));3302 });3303 });3304 });3305 describe('moving the group from one locked side to another into another group', function () {3306 describe('moving from locked to normal', function () {3307 describe('Group1', function () {3308 describe('moving into Group2', function () {3309 function additionalSpec() {3310 // Group2 should be the owner of Group1.3311 expect(!!headerCt.down('[text=Group2]').down('[text=Group1]')).toBe(true);3312 }3313 it('should work moving before the first nested header', function () {3314 runTest({3315 columns: columns,3316 locked: true,3317 order: '1,2,9,10,11,3,4,5,6,7,8,12,13,14,15,16,17,18',3318 sequence: [3319 ['groupHeader', 'subGroupHeader', false]3320 ],3321 subGroupHeader: 33322 }, additionalSpec);3323 });3324 it('should work moving after the last nested header', function () {3325 runTest({3326 columns: columns,3327 locked: true,3328 order: '1,2,9,10,11,12,13,14,15,16,3,4,5,6,7,8,17,18',3329 sequence: [3330 ['groupHeader', 15, true]3331 ]3332 });3333 }, additionalSpec);3334 it('should work moving into the middle', function () {3335 runTest({3336 columns: columns,3337 locked: true,3338 order: '1,2,9,10,11,12,13,14,15,3,4,5,6,7,8,16,17,18',3339 sequence: [3340 ['groupHeader', 14, true]3341 ]3342 }, additionalSpec);3343 runTest({3344 columns: columns,3345 locked: true,3346 order: '1,2,9,10,11,12,13,3,4,5,6,7,8,14,15,16,17,18',3347 sequence: [3348 ['groupHeader', 13, false]3349 ]3350 }, additionalSpec);3351 });3352 });3353 describe('moving into Group4', function () {3354 function additionalSpec() {3355 expect(!!headerCt.down('[text=Group2]').down('[text=Group4]').down('[text=Group1]').down('[text=Group3]')).toBe(true);3356 }3357 it('should work moving before the first nested header', function () {3358 runTest({3359 columns: columns,3360 locked: true,3361 order: '1,2,9,10,11,3,4,5,6,7,8,12,13,14,15,16,17,18',3362 sequence: [3363 ['groupHeader', 11, false]3364 ]3365 }, additionalSpec);3366 });3367 it('should work moving after the last nested header', function () {3368 runTest({3369 columns: columns,3370 locked: true,3371 order: '1,2,9,10,11,12,13,3,4,5,6,7,8,14,15,16,17,18',3372 sequence: [3373 ['groupHeader', 12, true]3374 ]3375 }, additionalSpec);3376 });3377 it('should work moving into the middle', function () {3378 runTest({3379 columns: columns,3380 locked: true,3381 order: '1,2,9,10,11,12,3,4,5,6,7,8,13,14,15,16,17,18',3382 sequence: [3383 ['groupHeader', 11, true]3384 ]3385 }, additionalSpec);3386 runTest({3387 columns: columns,3388 locked: true,3389 order: '1,2,9,10,11,12,3,4,5,6,7,8,13,14,15,16,17,18',3390 sequence: [3391 ['groupHeader', 12, false]3392 ]3393 }, additionalSpec);3394 });3395 });3396 });3397 describe('Group3', function () {3398 describe('moving into Group2', function () {3399 function additionalSpec() {3400 expect(!!headerCt.down('[text=Group2]').down('[text=Group3]')).toBe(true);3401 }3402 it('should work moving before the first nested header', function () {3403 runTest({3404 columns: columns,3405 locked: true,3406 order: '1,2,3,7,8,9,10,11,4,5,6,12,13,14,15,16,17,18',3407 sequence: [3408 ['groupHeader', 'subGroupHeader', false]3409 ],3410 groupHeader: 1,3411 subGroupHeader: 33412 }, additionalSpec);3413 });3414 it('should work moving after the last nested header', function () {3415 runTest({3416 columns: columns,3417 locked: true,3418 order: '1,2,3,7,8,9,10,11,12,13,14,15,16,4,5,6,17,18',3419 sequence: [3420 ['groupHeader', 15, true]3421 ],3422 groupHeader: 13423 }, additionalSpec);3424 });3425 it('should work moving into the middle', function () {3426 runTest({3427 columns: columns,3428 locked: true,3429 order: '1,2,3,7,8,9,10,11,12,13,14,15,4,5,6,16,17,18',3430 sequence: [3431 ['groupHeader', 14, true]3432 ],3433 groupHeader: 13434 }, additionalSpec);3435 runTest({3436 columns: columns,3437 locked: true,3438 order: '1,2,3,7,8,9,10,11,12,13,14,4,5,6,15,16,17,18',3439 sequence: [3440 ['groupHeader', 14, false]3441 ],3442 groupHeader: 13443 }, additionalSpec);3444 });3445 });3446 describe('moving into Group4', function () {3447 function additionalSpec() {3448 expect(!!headerCt.down('[text=Group2]').down('[text=Group4]').down('[text=Group3]')).toBe(true);3449 }3450 it('should work moving before the first nested header', function () {3451 runTest({3452 columns: columns,3453 locked: true,3454 order: '1,2,3,7,8,9,10,11,4,5,6,12,13,14,15,16,17,18',3455 sequence: [3456 ['groupHeader', 11, false]3457 ],3458 groupHeader: 13459 }, additionalSpec);3460 });3461 it('should work moving after the last nested header', function () {3462 runTest({3463 columns: columns,3464 locked: true,3465 order: '1,2,3,7,8,9,10,11,12,13,4,5,6,14,15,16,17,18',3466 sequence: [3467 ['groupHeader', 12, true]3468 ],3469 groupHeader: 13470 }, additionalSpec);3471 });3472 it('should work moving into the middle', function () {3473 runTest({3474 columns: columns,3475 locked: true,3476 order: '1,2,3,7,8,9,10,11,12,4,5,6,13,14,15,16,17,18',3477 sequence: [3478 ['groupHeader', 11, true]3479 ],3480 groupHeader: 13481 }, additionalSpec);3482 runTest({3483 columns: columns,3484 locked: true,3485 order: '1,2,3,7,8,9,10,11,12,4,5,6,13,14,15,16,17,18',3486 sequence: [3487 ['groupHeader', 12, false]3488 ],3489 groupHeader: 13490 }, additionalSpec);3491 });3492 });3493 });3494 });3495 describe('moving from normal to locked', function () {3496 describe('Group2', function () {3497 describe('moving into Group1', function () {3498 function additionalSpec() {3499 expect(!!headerCt.down('[text=Group1]').down('[text=Group2]')).toBe(true);3500 }3501 it('should work moving before the first nested header', function () {3502 runTest({3503 columns: columns,3504 locked: true,3505 order: '1,2,12,13,14,15,16,3,4,5,6,7,8,9,10,11,17,18',3506 sequence: [3507 ['groupHeader', 2, false]3508 ],3509 groupHeader: 23510 }, additionalSpec);3511 });3512 it('should work moving after the last nested header', function () {3513 runTest({3514 columns: columns,3515 locked: true,3516 order: '1,2,3,4,5,6,7,8,12,13,14,15,16,9,10,11,17,18',3517 sequence: [3518 ['groupHeader', 7, true]3519 ],3520 groupHeader: 23521 });3522 }, additionalSpec);3523 it('should work moving into the middle', function () {3524 runTest({3525 columns: columns,3526 locked: true,3527 order: '1,2,3,4,5,6,12,13,14,15,16,7,8,9,10,11,17,18',3528 sequence: [3529 ['groupHeader', 'subGroupHeader', true]3530 ],3531 groupHeader: 2,3532 subGroupHeader: 13533 }, additionalSpec);3534 runTest({3535 columns: columns,3536 locked: true,3537 order: '1,2,3,12,13,14,15,16,4,5,6,7,8,9,10,11,17,18',3538 sequence: [3539 ['groupHeader', 'subGroupHeader', false]3540 ],3541 groupHeader: 2,3542 subGroupHeader: 13543 }, additionalSpec);3544 });3545 });3546 describe('moving into Group3', function () {3547 function additionalSpec() {3548 expect(!!headerCt.down('[text=Group1]').down('[text=Group3]').down('[text=Group2]').down('[text=Group4]')).toBe(true);3549 }3550 it('should work moving before the first nested header', function () {3551 runTest({3552 columns: columns,3553 locked: true,3554 order: '1,2,3,12,13,14,15,16,4,5,6,7,8,9,10,11,17,18',3555 sequence: [3556 ['groupHeader', 3, false]3557 ],3558 groupHeader: 23559 }, additionalSpec);3560 });3561 it('should work moving after the last nested header', function () {3562 runTest({3563 columns: columns,3564 locked: true,3565 order: '1,2,3,4,5,6,12,13,14,15,16,7,8,9,10,11,17,18',3566 sequence: [3567 ['groupHeader', 5, true]3568 ],3569 groupHeader: 23570 }, additionalSpec);3571 });3572 it('should work moving into the middle', function () {3573 runTest({3574 columns: columns,3575 locked: true,3576 order: '1,2,3,4,12,13,14,15,16,5,6,7,8,9,10,11,17,18',3577 sequence: [3578 ['groupHeader', 4, false]3579 ],3580 groupHeader: 23581 }, additionalSpec);3582 runTest({3583 columns: columns,3584 locked: true,3585 order: '1,2,3,4,5,12,13,14,15,16,6,7,8,9,10,11,17,18',3586 sequence: [3587 ['groupHeader', 4, true]3588 ],3589 groupHeader: 23590 }, additionalSpec);3591 });3592 });3593 });3594 describe('Group4', function () {3595 describe('moving into Group1', function () {3596 function additionalSpec() {3597 expect(!!headerCt.down('[text=Group1]').down('[text=Group4]')).toBe(true);3598 }3599 it('should work moving before the first nested header', function () {3600 runTest({3601 columns: columns,3602 locked: true,3603 order: '1,2,12,13,3,4,5,6,7,8,9,10,11,14,15,16,17,18',3604 sequence: [3605 ['groupHeader', 2, false]3606 ],3607 groupHeader: 33608 }, additionalSpec);3609 });3610 it('should work moving after the last nested header', function () {3611 runTest({3612 columns: columns,3613 locked: true,3614 order: '1,2,3,4,5,6,7,8,12,13,9,10,11,14,15,16,17,18',3615 sequence: [3616 ['groupHeader', 7, true]3617 ],3618 groupHeader: 33619 }, additionalSpec);3620 });3621 it('should work moving into the middle', function () {3622 runTest({3623 columns: columns,3624 locked: true,3625 order: '1,2,3,12,13,4,5,6,7,8,9,10,11,14,15,16,17,18',3626 sequence: [3627 ['groupHeader', 'subGroupHeader', false]3628 ],3629 groupHeader: 3,3630 subGroupHeader: 13631 }, additionalSpec);3632 runTest({3633 columns: columns,3634 locked: true,3635 order: '1,2,3,4,5,6,12,13,7,8,9,10,11,14,15,16,17,18',3636 sequence: [3637 ['groupHeader', 'subGroupHeader', true]3638 ],3639 groupHeader: 3,3640 subGroupHeader: 13641 }, additionalSpec);3642 });3643 });3644 describe('moving into Group3', function () {3645 function additionalSpec() {3646 expect(!!headerCt.down('[text=Group1]').down('[text=Group3]').down('[text=Group4]')).toBe(true);3647 }3648 it('should work moving before the first nested header', function () {3649 runTest({3650 columns: columns,3651 locked: true,3652 order: '1,2,3,12,13,4,5,6,7,8,9,10,11,14,15,16,17,18',3653 sequence: [3654 ['groupHeader', 3, false]3655 ],3656 groupHeader: 33657 }, additionalSpec);3658 });3659 it('should work moving after the last nested header', function () {3660 runTest({3661 columns: columns,3662 locked: true,3663 order: '1,2,3,4,5,6,12,13,7,8,9,10,11,14,15,16,17,18',3664 sequence: [3665 ['groupHeader', 5, true]3666 ],3667 groupHeader: 33668 }, additionalSpec);3669 });3670 it('should work moving into the middle', function () {3671 runTest({3672 columns: columns,3673 locked: true,3674 order: '1,2,3,4,12,13,5,6,7,8,9,10,11,14,15,16,17,18',3675 sequence: [3676 ['groupHeader', 4, false]3677 ],3678 groupHeader: 33679 }, additionalSpec);3680 runTest({3681 columns: columns,3682 locked: true,3683 order: '1,2,3,4,5,12,13,6,7,8,9,10,11,14,15,16,17,18',3684 sequence: [3685 ['groupHeader', 5, false]3686 ],3687 groupHeader: 33688 }, additionalSpec);3689 });3690 });3691 });3692 });3693 });3694 });...
pac-funcs-test.js
Source:pac-funcs-test.js
...24}25function runTests(name, tests) {26 var undefined_var;27 for ( var i = 0; i < tests.length; i++) {28 runTest(name, tests[i]);29 }30}31function runTest(name, test) {32 var expectedVal = test[0];33 var args = test.slice(1);34 var returnVal;35 try {36 returnVal = name.apply(null, args);37 } catch (e) {38 returnVal = e;39 }40 if (returnVal === expectedVal) {41 java.lang.System.out.println("Passed: " + name.name + "(" + args.join(", ") + ")");42 testsPassed++;43 } else {44 java.lang.System.out.println("FAILED: " + name.name + "(" + args.join(", ") + ")");45 java.lang.System.out.println(" Expected '" + expectedVal + "' but got '" + returnVal + "'");46 testsFailed++;47 }48}49function testIsPlainHostName() {50 var tests = [51 [ false, "icedtea.classpath.org" ],52 [ false, "classpath.org" ],53 [ true, "org" ],54 [ true, "icedtea" ],55 [ false, ".icedtea.classpath.org" ],56 [ false, "icedtea." ],57 [ false, "icedtea.classpath." ]58 ];59 runTests(isPlainHostName, tests);60}61function testDnsDomainIs() {62 var tests = [63 [ true, "icedtea.classpath.org", "icedtea.classpath.org" ],64 [ true, "icedtea.classpath.org", ".classpath.org" ],65 [ true, "icedtea.classpath.org", ".org" ],66 [ false, "icedtea.classpath.org", "icedtea.classpath.com" ],67 [ false, "icedtea.classpath.org", "icedtea.classpath" ],68 [ false, "icedtea.classpath", "icedtea.classpath.org" ],69 [ false, "icedtea", "icedtea.classpath.org" ]70 ];71 runTests(dnsDomainIs, tests);72}73function testLocalHostOrDomainIs() {74 var tests = [75 [ true, "icedtea.classpath.org", "icedtea.classpath.org" ],76 [ true, "icedtea", "icedtea.classpath.org" ],77 [ false, "icedtea.classpath.org", "icedtea.classpath.com" ],78 [ false, "icedtea.classpath", "icedtea.classpath.org" ],79 [ false, "foo.classpath.org", "icedtea.classpath.org" ],80 [ false, "foo", "icedtea.classpath.org" ]81 ];82 runTests(localHostOrDomainIs, tests);83}84function testIsResolvable() {85 var tests = [86 [ true, "icedtea.classpath.org", "icedtea.classpath.org" ],87 [ true, "classpath.org" ],88 [ false, "NotIcedTeaHost" ],89 [ false, "foobar.classpath.org" ],90 [ false, "icedtea.classpath.com" ]91 ];92 runTests(isResolvable, tests);93}94function testIsInNet() {95 var parts = ICEDTEA_CLASSPATH_ORG_IP.split("\.");96 var fakeParts = ICEDTEA_CLASSPATH_ORG_IP.split("\.");97 fakeParts[0] = fakeParts[0] + 1;98 function createIp(array) {99 return array[0] + "." + array[1] + "." + array[2] + "." + array[3];100 }101 var tests = [102 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "255.255.255.255"],103 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "255.255.255.0"],104 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "255.255.0.0"],105 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "255.0.0.0"],106 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "0.0.0.0"],107 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "255.255.255.255"],108 [ true, "icedtea.classpath.org", ICEDTEA_CLASSPATH_ORG_IP, "0.0.0.0"],109 [ true, "icedtea.classpath.org", createIp(parts), "255.255.255.255" ],110 [ false, "icedtea.classpath.org", createIp(fakeParts), "255.255.255.255"],111 [ false, "icedtea.classpath.org", createIp(fakeParts), "255.255.255.0"],112 [ false, "icedtea.classpath.org", createIp(fakeParts), "255.255.0.0"],113 [ false, "icedtea.classpath.org", createIp(fakeParts), "255.0.0.0"],114 [ true, "icedtea.classpath.org", createIp(fakeParts), "0.0.0.0"]115 ];116 runTests(isInNet, tests);117}118function testDnsResolve() {119 var tests = [120 [ ICEDTEA_CLASSPATH_ORG_IP, "icedtea.classpath.org" ],121 //[ CLASSPATH_ORG_IP, "classpath.org" ],122 [ "127.0.0.1", "localhost" ]123 ];124 runTests(dnsResolve, tests);125}126function testDnsDomainLevels() {127 var tests = [128 [ 0, "org" ],129 [ 1, "classpath.org" ],130 [ 2, "icedtea.classpath.org" ],131 [ 3, "foo.icedtea.classpath.org" ]132 ];133 runTests(dnsDomainLevels, tests);134}135function testShExpMatch() {136 var tests = [137 [ true, "icedtea.classpath.org", "icedtea.classpath.org"],138 [ false, "icedtea.classpath.org", ".org"],139 [ false, "icedtea.classpath.org", "icedtea."],140 [ false, "icedtea", "icedtea.classpath.org"],141 [ true, "icedtea.classpath.org", "*" ],142 [ true, "icedtea.classpath.org", "*.classpath.org" ],143 [ true, "http://icedtea.classpath.org", "*.classpath.org" ],144 [ true, "http://icedtea.classpath.org/foobar/", "*.classpath.org/*" ],145 [ true, "http://icedtea.classpath.org/foobar/", "*/foobar/*" ],146 [ true, "http://icedtea.classpath.org/foobar/", "*foobar*" ],147 [ true, "http://icedtea.classpath.org/foobar/", "*foo*" ],148 [ false, "http://icedtea.classpath.org/foobar/", "*/foo/*" ],149 [ false, "http://icedtea.classpath.org/foobar/", "*/foob/*" ],150 [ false, "http://icedtea.classpath.org/foobar/", "*/fooba/*" ],151 [ false, "http://icedtea.classpath.org/foo/", "*foobar*" ],152 [ true, "1", "?" ],153 [ true, "12", "??" ],154 [ true, "123", "1?3" ],155 [ true, "123", "?23" ],156 [ true, "123", "12?" ],157 [ true, "1234567890", "??????????" ],158 [ false, "1234567890", "?????????" ],159 [ false, "123", "1?1" ],160 [ false, "123", "??" ],161 [ true, "http://icedtea.classpath.org/f1/", "*/f?/*" ],162 [ true, "http://icedtea1.classpath.org/f1/", "*icedtea?.classpath*/f?/*" ],163 [ false, "http://icedtea.classpath.org/f1/", "*/f2/*" ],164 [ true, "http://icedtea.classpath.org/f1/", "*/f?/*" ],165 [ false, "http://icedtea.classpath.org/f1", "f?*"],166 [ false, "http://icedtea.classpath.org/f1", "f?*"],167 [ false, "http://icedtea.classpath.org/f1", "f?*"],168 [ true, "http://icedtea.classpath.org/foobar/", "*.classpath.org/*" ],169 [ true, "http://icedtea.classpath.org/foobar/", "*.classpath.org/*" ],170 [ true, "http://icedtea.classpath.org/foobar/", "*.classpath.org/*" ],171 [ true, "http://icedtea.classpath.org/foo.php?id=bah", "*foo.php*" ],172 [ false, "http://icedtea.classpath.org/foo_php?id=bah", "*foo.php*" ]173 ];174 runTests(shExpMatch, tests);175}176function testWeekdayRange() {177 var today = new Date();178 var day = today.getDay();179 function dayToStr(day) {180 switch (day) {181 case -2: return "FRI";182 case -1: return "SAT";183 case 0: return "SUN";184 case 1: return "MON";185 case 2: return "TUE";186 case 3: return "WED";187 case 4: return "THU";188 case 5: return "FRI";189 case 6: return "SAT";190 case 7: return "SUN";191 case 8: return "MON";192 default: return "FRI";193 }194 }195 var tests = [196 [ true, dayToStr(day) ],197 [ false, dayToStr(day+1) ],198 [ false, dayToStr(day-1) ],199 ];200 runTests(weekdayRange, tests);201}202/** Returns an array: [day, month, year] */203function incDate() {204 if ((arguments.length >= 3) && (arguments.length % 2 === 1)) {205 var date = arguments[0];206 var result = date;207 var index = 1;208 while (index < arguments.length) {209 var whichThing = arguments[index];210 var by = arguments[index+1];211 switch (whichThing) {212 case 'year':213 result = new Date(result.getFullYear()+by, result.getMonth(), result.getDate());214 break;215 case 'month':216 result = new Date(result.getFullYear(), result.getMonth()+by, result.getDate());217 break;218 case 'day':219 result = new Date(result.getFullYear(), result.getMonth(), result.getDate()+by);220 break;221 }222 index += 2;223 }224 return [result.getDate(), result.getMonth(), result.getFullYear()];225 }226 throw "Please call incDate properly";227}228function monthToStr(month) {229 switch (month) {230 case -1: return "DEC";231 case 0: return "JAN";232 case 1: return "FEB";233 case 2: return "MAR";234 case 3: return "APR";235 case 4: return "MAY";236 case 5: return "JUN";237 case 6: return "JUL";238 case 7: return "AUG";239 case 8: return "SEP";240 case 9: return "OCT";241 case 10: return "NOV";242 case 11: return "DEC";243 case 12: return "JAN";244 default: throw "Invalid Month" + month;245 }246}247function testDateRange() {248 {249 var current = new Date();250 var date = current.getDate();251 var month = current.getMonth();252 var year = current.getFullYear();253 var today = incDate(current, 'day', 0);254 var tomorrow = incDate(current, 'day', 1);255 var yesterday = incDate(current, 'day', -1);256 runTest(dateRange, [ true, date ]);257 runTest(dateRange, [ false, tomorrow[0] ]);258 runTest(dateRange, [ false, yesterday[0] ]);259 runTest(dateRange, [ true, monthToStr(month) ]);260 runTest(dateRange, [ false, monthToStr(month+1) ]);261 runTest(dateRange, [ false, monthToStr(month-1) ]);262 runTest(dateRange, [ true, year ]);263 runTest(dateRange, [ false, year - 1]);264 runTest(dateRange, [ false, year + 1]);265 runTest(dateRange, [ true, date, date ]);266 runTest(dateRange, [ true, today[0], tomorrow[0] ]);267 runTest(dateRange, [ true, yesterday[0], today[0] ]);268 runTest(dateRange, [ true, yesterday[0], tomorrow[0] ]);269 runTest(dateRange, [ false, tomorrow[0], yesterday[0] ]);270 runTest(dateRange, [ false, incDate(current,'day',-2)[0], yesterday[0] ]);271 runTest(dateRange, [ false, tomorrow[0], incDate(current,'day',2)[0] ]);272 runTest(dateRange, [ true, monthToStr(month), monthToStr(month) ]);273 runTest(dateRange, [ true, monthToStr(month), monthToStr(month+1) ]);274 runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month) ]);275 runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month+1) ]);276 runTest(dateRange, [ true, "JAN", "DEC" ]);277 runTest(dateRange, [ true, "FEB", "JAN" ]);278 runTest(dateRange, [ true, "DEC", "NOV" ]);279 runTest(dateRange, [ true, "JUL", "JUN"]);280 runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month+1) ]);281 runTest(dateRange, [ false, monthToStr(month-1), monthToStr(month-1) ]);282 runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month-1) ]);283 runTest(dateRange, [ true, year, year ]);284 runTest(dateRange, [ true, year, year+1 ]);285 runTest(dateRange, [ true, year-1, year ]);286 runTest(dateRange, [ true, year-1, year+1 ]);287 runTest(dateRange, [ false, year-2, year-1 ]);288 runTest(dateRange, [ false, year+1, year+1 ]);289 runTest(dateRange, [ false, year+1, year+2 ]);290 runTest(dateRange, [ false, year+1, year-1 ]);291 runTest(dateRange, [ true, date, monthToStr(month) , date, monthToStr(month) ]);292 runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , date, monthToStr(month) ]);293 runTest(dateRange, [ false, yesterday[0], monthToStr(yesterday[1]) , yesterday[0], monthToStr(yesterday[1]) ]);294 runTest(dateRange, [ true, date, monthToStr(month) , tomorrow[0], monthToStr(tomorrow[1]) ]);295 runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);296 runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);297 runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , yesterday[0], monthToStr(yesterday[1]) ]);298 }299 {300 var lastMonth = incDate(new Date(), 'month', -1);301 var thisMonth = incDate(new Date(), 'month', 0);302 var nextMonth = incDate(new Date(), 'month', +1);303 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , thisMonth[0], monthToStr(thisMonth[1]) ]);304 runTest(dateRange, [ true, thisMonth[0], monthToStr(thisMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);305 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);306 var date1 = incDate(new Date(), 'day', +1, 'month', -1);307 var date2 = incDate(new Date(), 'day', -1, 'month', +1);308 runTest(dateRange, [ true, date1[0], monthToStr(date1[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);309 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , date2[0], monthToStr(date2[1]) ]);310 runTest(dateRange, [ false, nextMonth[0], monthToStr(nextMonth[1]) , lastMonth[0], monthToStr(lastMonth[1]) ]);311 var date3 = incDate(new Date(), 'day', +1, 'month', +1);312 var date4 = incDate(new Date(), 'day', +1, 'month', -1);313 runTest(dateRange, [ false, date3[0], monthToStr(date3[1]) , date4[0], monthToStr(date4[1]) ]);314 var date5 = incDate(new Date(), 'day', -1, 'month', -1);315 runTest(dateRange, [ false, date2[0], monthToStr(date2[1]) , date5[0], monthToStr(date5[1]) ]);316 runTest(dateRange, [ true, 1, "JAN", 31, "DEC" ]);317 runTest(dateRange, [ true, 2, "JAN", 1, "JAN" ]);318 var month = new Date().getMonth();319 runTest(dateRange, [ false, 1, monthToStr(month+1), 31, monthToStr(month+1) ]);320 runTest(dateRange, [ false, 1, monthToStr(month-1), 31, monthToStr(month-1) ]);321 }322 {323 var lastMonth = incDate(new Date(), 'month', -1);324 var thisMonth = incDate(new Date(), 'month', 0);325 var nextMonth = incDate(new Date(), 'month', +1);326 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]);327 runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]);328 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);329 runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);330 runTest(dateRange, [ true, monthToStr(0), year, monthToStr(11), year ]);331 runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]);332 runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);333 runTest(dateRange, [ false, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]);334 var lastYear = incDate(new Date(), 'year', -1);335 var nextYear = incDate(new Date(), 'year', +1);336 runTest(dateRange, [ false, monthToStr(lastYear[1]), lastYear[2], monthToStr(lastMonth[1]), lastMonth[2] ]);337 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextYear[1]), nextYear[2] ]);338 var year = new Date().getFullYear();339 var month = new Date().getMonth();340 runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year ]);341 runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year+1 ]);342 runTest(dateRange, [ true, monthToStr(0), year, monthToStr(0), year+1 ]);343 runTest(dateRange, [ true, monthToStr(0), year-1, monthToStr(0), year+1 ]);344 runTest(dateRange, [ false, monthToStr(0), year-1, monthToStr(11), year-1 ]);345 runTest(dateRange, [ false, monthToStr(0), year+1, monthToStr(11), year+1 ]);346 }347 {348 var today = incDate(new Date(), 'day', 0);349 var yesterday = incDate(new Date(), 'day', -1);350 var tomorrow = incDate(new Date(), 'day', +1);351 runTest(dateRange, [ true,352 today[0], monthToStr(today[1]), today[2], today[0], monthToStr(today[1]), today[2] ]);353 runTest(dateRange, [ true,354 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);355 }356 {357 var dayLastMonth = incDate(new Date(), 'day', -1, 'month', -1);358 var dayNextMonth = incDate(new Date(), 'day', +1, 'month', +1);359 runTest(dateRange, [ true,360 dayLastMonth[0], monthToStr(dayLastMonth[1]), dayLastMonth[2], dayNextMonth[0], monthToStr(dayNextMonth[1]), dayNextMonth[2] ]);361 }362 {363 var dayLastYear = incDate(new Date(), 'day', -1, 'month', -1, 'year', -1);364 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);365 runTest(dateRange, [ true,366 dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);367 }368 {369 var dayLastYear = incDate(new Date(), 'day', +1, 'month', -1, 'year', -1);370 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);371 runTest(dateRange, [ true,372 dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);373 }374 {375 var tomorrow = incDate(new Date(), 'day', +1);376 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);377 runTest(dateRange, [ false,378 tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);379 }380 {381 var nextMonth = incDate(new Date(), 'month', +1);382 var nextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);383 runTest(dateRange, [ false,384 nextMonth[0], monthToStr(nextMonth[1]), nextMonth[2], nextYear[0], monthToStr(nextYear[1]), nextYear[2] ]);385 }386 {387 runTest(dateRange, [ true, 1, monthToStr(0), 0, 31, monthToStr(11), 100000 ]);388 runTest(dateRange, [ true, 1, monthToStr(0), year, 31, monthToStr(11), year ]);389 runTest(dateRange, [ true, 1, monthToStr(0), year-1, 31, monthToStr(11), year+1 ]);390 runTest(dateRange, [ false, 1, monthToStr(0), year-1, 31, monthToStr(11), year-1 ]);391 runTest(dateRange, [ false, 1, monthToStr(0), year+1, 31, monthToStr(11), year+1 ]);392 }393}394function testDateRange2() {395 var dates = [ 396 new Date("January 31, 2011 3:33:33"),397 new Date("February 28, 2011 3:33:33"),398 new Date("February 29, 2012 3:33:33"),399 new Date("March 31, 2011 3:33:33"),400 new Date("April 30, 2011 3:33:33"),401 new Date("May 31, 2011 3:33:33"),402 new Date("June 30, 2011 3:33:33"),403 new Date("July 31, 2011 3:33:33"),404 new Date("August 31, 2011 3:33:33"),405 new Date("September 30, 2011 3:33:33"),406 new Date("October 31, 2011 3:33:33"),407 new Date("November 30, 2011 3:33:33"),408 new Date("December 31, 2011 3:33:33"),409]410 for (var i = 0; i < dates.length; i++) {411 var current = dates[i];412 var today = incDate(current, 'day', 0);413 var yesterday = incDate(current, 'day', -1);414 var tomorrow = incDate(current, 'day', 1);415 var aYearFromNow = new Date(current.getFullYear()+1, current.getMonth()+1, current.getDate()+1);416 var later = [aYearFromNow.getDate(), aYearFromNow.getMonth(), aYearFromNow.getFullYear()];417 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,418 today[0], monthToStr(today[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);419 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,420 yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);421 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,422 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);423 runTest(isDateInRange_internallForIcedTeaWebTesting, [ false, current,424 tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], later[0], monthToStr(later[1]), later[2] ]);425 }426}427function testDateRange3() {428 var dates = [ 429 new Date("January 1, 2011 1:11:11"),430 new Date("February 1, 2011 1:11:11"),431 new Date("March 1, 2011 1:11:11"),432 new Date("April 1, 2011 1:11:11"),433 new Date("May 1, 2011 1:11:11"),434 new Date("June 1, 2011 1:11:11"),435 new Date("July 1, 2011 1:11:11"),436 new Date("August 1, 2011 1:11:11"),437 new Date("September 1, 2011 1:11:11"),438 new Date("October 1, 2011 1:11:11"),439 new Date("November 1, 2011 1:11:11"),440 new Date("December 1, 2011 1:11:11"),441 ]442 for (var i = 0; i < dates.length; i++) {443 var current = dates[i];444 var yesterday = incDate(current,'day',-1);445 var today = incDate(current,'day',0);446 var tomorrow = incDate(current,'day',1);447 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,448 yesterday[0], monthToStr(yesterday[1]) , today[0], monthToStr(today[1]) ]);449 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,450 yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);451 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current,452 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);453 }454}455function testTimeRange() {456 var now = new Date();457 var hour = now.getHours();458 var min = now.getMinutes();459 var sec = now.getSeconds();460 function toHour(input) {461 if (input < 0) {462 while (input < 0) {463 input = input + 24;464 }465 return (input % 24);...
FilterTestCase.js
Source:FilterTestCase.js
1require(['doh/main', 'dojo/on', 'dojo/_base/html', 'dojo/Deferred', 'jimu/dijit/Filter', 'esri/request'],2 function(doh, on, html, Deferred, Filter, esriRequest) {3 if (window.currentDijit) {4 window.currentDijit.destroy();5 }6 window.currentDijit = null;7 html.empty('jimuDijitContainer');8 var urls = ['http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/0',9 'http://discomap.eea.europa.eu/arcgis/rest/services/NoiseWatch/NoiseWatch_Overview_WM/MapServer/8',10 'http://services2.arcgis.com/N4cKzJ9dzXmsPNRs/arcgis/rest/services/aquatic/FeatureServer/0',//test date field of hosted services11 'http://services1.arcgis.com/oC086ufSSQ6Avnw2/arcgis/rest/services/utf8-competitor/FeatureServer/0'//test unicode field of hosted services12 ];13 var definitionObject = {};14 var currentUrl = '', currentLayerDefinition = null;15 var filter = new Filter({16 url: urls[0]17 });18 filter.placeAt('jimuDijitContainer');19 filter.startup();20 window.parent.currentDijit = window.currentDijit = filter;21 function setUrlIndex(i) {22 filter.reset();23 currentUrl = urls[i];24 currentLayerDefinition = definitionObject[currentUrl];25 }26 function buildByExpr(expr) {27 var def = new doh.Deferred();28 filter.buildByExpr(currentUrl, expr, currentLayerDefinition).then(function() {29 var url = filter.url;30 var definition = filter._layerDefinition;31 definitionObject[url] = definition;32 var json = filter.toJson();33 if (json && json.expr === expr) {34 def.resolve();35 } else {36 def.reject();37 }38 }, function() {39 def.reject();40 });41 return def;42 }43 doh.register("buildByExpr/toJson", [{44 name: 'stringOperatorIs-value',45 timeout: 10000,46 setUp: function() {47 setUrlIndex(0);48 },49 runTest: function() {50 return buildByExpr("CITY_NAME = 'Beijing'");51 }52 }, {53 name: 'stringOperatorIs-value-HostedService-Latin',54 timeout: 10000,55 setUp: function() {56 setUrlIndex(2);57 },58 runTest: function() {59 return buildByExpr("PLNM = 'Bladderwort'");60 }61 }, {62 name: 'stringOperatorIs-value-HostedService-NotLatin',63 timeout: 10000,64 setUp: function() {65 setUrlIndex(2);66 },67 runTest: function() {68 return buildByExpr("PLNM = N'ä¸å½'");69 }70 }, {71 name: 'stringOperatorIsNot-value',72 timeout: 10000,73 setUp: function() {74 setUrlIndex(0);75 },76 runTest: function() {77 return buildByExpr("CITY_NAME <> 'Beijing'");78 }79 }, {80 name: 'stringOperatorIsNot-value-HostedService-Latin',81 timeout: 10000,82 setUp: function() {83 setUrlIndex(2);84 },85 runTest: function() {86 return buildByExpr("PLNM <> 'Bladderwort'");87 }88 }, {89 name: 'stringOperatorIsNot-value-HostedService-NotLatin',90 timeout: 10000,91 setUp: function() {92 setUrlIndex(2);93 },94 runTest: function() {95 return buildByExpr("PLNM <> N'ä¸å½'");96 }97 }, {98 name: 'stringOperatorStartsWith-value-IgnoreCaseSensitive',99 timeout: 10000,100 setUp: function() {101 setUrlIndex(0);102 },103 runTest: function() {104 return buildByExpr("UPPER(CITY_NAME) LIKE UPPER('Beijing%')");105 }106 }, {107 name: 'stringOperatorStartsWith-value-CaseSensitive',108 timeout: 10000,109 setUp: function(){110 setUrlIndex(0);111 },112 runTest: function(){113 return buildByExpr("CITY_NAME LIKE 'Beijing%'");114 }115 }, {116 name: 'stringOperatorStartsWith-value-HostedService-Latin',117 timeout: 10000,118 setUp: function() {119 setUrlIndex(2);120 },121 runTest: function() {122 return buildByExpr("UPPER(PLNM) LIKE UPPER('China%')");123 }124 }, {125 name: 'stringOperatorStartsWith-value-HostedService-NotLatin',126 timeout: 10000,127 setUp: function() {128 setUrlIndex(2);129 },130 runTest: function() {131 return buildByExpr("UPPER(PLNM) LIKE UPPER(N'ä¸å½%')");132 }133 }, {134 name: 'stringOperatorEndsWith-value-IgnoreCaseSensitive',135 timeout: 10000,136 setUp: function() {137 setUrlIndex(0);138 },139 runTest: function() {140 return buildByExpr("UPPER(CITY_NAME) LIKE UPPER('%Beijing')");141 }142 }, {143 name: 'stringOperatorEndsWith-value-CaseSensitive',144 timeout: 10000,145 setUp: function(){146 setUrlIndex(0);147 },148 runTest: function(){149 return buildByExpr("CITY_NAME LIKE '%Beijing'");150 }151 }, {152 name: 'stringOperatorEndsWith-value-CaseSensitive-HostedService-Latin',153 timeout: 10000,154 setUp: function(){155 setUrlIndex(2);156 },157 runTest: function(){158 return buildByExpr("UPPER(PLNM) LIKE UPPER('%China')");159 }160 }, {161 name: 'stringOperatorEndsWith-value-CaseSensitive-HostedService-NotLatin',162 timeout: 10000,163 setUp: function(){164 setUrlIndex(2);165 },166 runTest: function(){167 return buildByExpr("UPPER(PLNM) LIKE UPPER(N'%ä¸å½')");168 }169 }, {170 name: 'stringOperatorContains-value-IgnoreCaseSensitive',171 timeout: 10000,172 setUp: function() {173 setUrlIndex(0);174 },175 runTest: function() {176 return buildByExpr("UPPER(CITY_NAME) LIKE UPPER('%Beijing%')");177 }178 }, {179 name: 'stringOperatorContains-value-CaseSensitive',180 timeout: 10000,181 setUp: function(){182 setUrlIndex(0);183 },184 runTest: function(){185 return buildByExpr("CITY_NAME LIKE '%Beijing%'");186 }187 }, {188 name: 'stringOperatorContains-value-HostedService-Latin',189 timeout: 10000,190 setUp: function(){191 setUrlIndex(2);192 },193 runTest: function(){194 return buildByExpr("UPPER(PLNM) LIKE UPPER('%China%')");195 }196 }, {197 name: 'stringOperatorContains-value-HostedService-NotLatin',198 timeout: 10000,199 setUp: function(){200 setUrlIndex(2);201 },202 runTest: function(){203 return buildByExpr("UPPER(PLNM) LIKE UPPER(N'%ä¸å½%')");204 }205 }, {206 name: 'stringOperatorDoesNotContain-value-IgnoreCaseSensitive',207 timeout: 10000,208 setUp: function() {209 setUrlIndex(0);210 },211 runTest: function() {212 return buildByExpr("UPPER(CITY_NAME) NOT LIKE UPPER('%Beijing%')");213 }214 }, {215 name: 'stringOperatorDoesNotContain-value-CaseSensitive',216 timeout: 10000,217 setUp: function(){218 setUrlIndex(0);219 },220 runTest: function(){221 return buildByExpr("CITY_NAME NOT LIKE '%Beijing%'");222 }223 }, {224 name: 'stringOperatorDoesNotContain-value-HostedService-Latin',225 timeout: 10000,226 setUp: function(){227 setUrlIndex(2);228 },229 runTest: function(){230 return buildByExpr("UPPER(PLNM) NOT LIKE UPPER('%China%')");231 }232 }, {233 name: 'stringOperatorDoesNotContain-value-HostedService-NotLatin',234 timeout: 10000,235 setUp: function(){236 setUrlIndex(2);237 },238 runTest: function(){239 return buildByExpr("UPPER(PLNM) NOT LIKE UPPER(N'%ä¸å½%')");240 }241 }, {242 name: 'stringOperatorIsBlank',243 timeout: 10000,244 setUp: function() {245 setUrlIndex(0);246 },247 runTest: function() {248 return buildByExpr("CITY_NAME IS NULL");249 }250 }, {251 name: 'stringOperatorIsBlank-HostedService',252 timeout: 10000,253 setUp: function() {254 setUrlIndex(2);255 },256 runTest: function() {257 return buildByExpr("PLNM IS NULL");258 }259 }, {260 name: 'stringOperatorIsNotBlank',261 timeout: 10000,262 setUp: function() {263 setUrlIndex(0);264 },265 runTest: function() {266 return buildByExpr("CITY_NAME IS NOT NULL");267 }268 }, {269 name: 'stringOperatorIsNotBlank-HostedService',270 timeout: 10000,271 setUp: function() {272 setUrlIndex(2);273 },274 runTest: function() {275 return buildByExpr("PLNM IS NOT NULL");276 }277 }, {278 name: 'stringOperatorIs-field',279 timeout: 10000,280 setUp: function() {281 setUrlIndex(0);282 },283 runTest: function() {284 return buildByExpr("CITY_NAME = POP_CLASS");285 }286 }, {287 name: 'stringOperatorIs-field-HostedService',288 timeout: 10000,289 setUp: function() {290 setUrlIndex(2);291 },292 runTest: function() {293 return buildByExpr("PLNM = SEDTP");294 }295 }, {296 name: 'stringOperatorIsNot-field',297 timeout: 10000,298 setUp: function() {299 setUrlIndex(0);300 },301 runTest: function() {302 return buildByExpr("CITY_NAME <> POP_CLASS");303 }304 }, {305 name: 'stringOperatorIsNot-field-HostedService',306 timeout: 10000,307 setUp: function() {308 setUrlIndex(2);309 },310 runTest: function() {311 return buildByExpr("PLNM <> SEDTP");312 }313 }, {314 name: 'numberOperatorIs-value',315 timeout: 10000,316 setUp: function() {317 setUrlIndex(0);318 },319 runTest: function() {320 return buildByExpr("POP = 123");321 }322 }, {323 name: 'numberOperatorIsNot-value',324 timeout: 10000,325 setUp: function() {326 setUrlIndex(0);327 },328 runTest: function() {329 return buildByExpr("POP <> 123");330 }331 }, {332 name: 'numberOperatorIsAtLeast-value',333 timeout: 10000,334 setUp: function() {335 setUrlIndex(0);336 },337 runTest: function() {338 return buildByExpr("POP >= 123");339 }340 }, {341 name: 'numberOperatorIsLessThan-value',342 timeout: 10000,343 setUp: function() {344 setUrlIndex(0);345 },346 runTest: function() {347 return buildByExpr("POP < 123");348 }349 }, {350 name: 'numberOperatorIsAtMost-value',351 timeout: 10000,352 setUp: function() {353 setUrlIndex(0);354 },355 runTest: function() {356 return buildByExpr("POP <= 123");357 }358 }, {359 name: 'numberOperatorIsGreaterThan-value',360 timeout: 10000,361 setUp: function() {362 setUrlIndex(0);363 },364 runTest: function() {365 return buildByExpr("POP > 123");366 }367 }, {368 name: 'numberOperatorIsBetween-value',369 timeout: 10000,370 setUp: function() {371 setUrlIndex(0);372 },373 runTest: function() {374 return buildByExpr("POP BETWEEN 13 AND 23");375 }376 }, {377 name: 'numberOperatorIsNotBetween-value',378 timeout: 10000,379 setUp: function() {380 setUrlIndex(0);381 },382 runTest: function() {383 return buildByExpr("POP NOT BETWEEN 13 AND 23");384 }385 }, {386 name: 'numberOperatorIsBlank',387 timeout: 10000,388 setUp: function() {389 setUrlIndex(0);390 },391 runTest: function() {392 return buildByExpr("POP IS NULL");393 }394 }, {395 name: 'numberOperatorIsNotBlank',396 timeout: 10000,397 setUp: function() {398 setUrlIndex(0);399 },400 runTest: function() {401 return buildByExpr("POP IS NOT NULL");402 }403 }, {404 name: 'dateOperatorIsOn-value',405 timeout: 60000,406 setUp: function() {407 setUrlIndex(1);408 },409 runTest: function() {410 return buildByExpr("created_date BETWEEN timestamp '2010-06-17 00:00:00' AND timestamp '2010-06-17 23:59:59'");411 }412 }, {413 name: 'dateOperatorIsOn-value-HostedService',414 timeout: 60000,415 setUp: function() {416 setUrlIndex(2);417 },418 runTest: function() {419 return buildByExpr("Dates BETWEEN '2015-02-02 00:00:00' AND '2015-02-02 23:59:59'");420 }421 }, {422 name: 'dateOperatorIsNotOn-value',423 timeout: 10000,424 setUp: function() {425 setUrlIndex(1);426 },427 runTest: function() {428 return buildByExpr("created_date NOT BETWEEN timestamp '2010-06-17 00:00:00' AND timestamp '2010-06-17 23:59:59'");429 }430 }, {431 name: 'dateOperatorIsNotOn-value-HostedService',432 timeout: 10000,433 setUp: function() {434 setUrlIndex(2);435 },436 runTest: function() {437 return buildByExpr("Dates NOT BETWEEN '2015-02-02 00:00:00' AND '2015-02-02 23:59:59'");438 }439 }, {440 name: 'dateOperatorIsBefore-value',441 timeout: 10000,442 setUp: function() {443 setUrlIndex(1);444 },445 runTest: function() {446 return buildByExpr("created_date < timestamp '2010-06-17 00:00:00'");447 }448 }, {449 name: 'dateOperatorIsBefore-value-HostedService',450 timeout: 10000,451 setUp: function() {452 setUrlIndex(2);453 },454 runTest: function() {455 return buildByExpr("Dates < '2015-02-02 00:00:00'");456 }457 }, {458 name: 'dateOperatorIsAfter-value',459 timeout: 10000,460 setUp: function() {461 setUrlIndex(1);462 },463 runTest: function() {464 return buildByExpr("created_date > timestamp '2010-06-17 23:59:59'");465 }466 }, {467 name: 'dateOperatorIsAfter-value-HostedService',468 timeout: 10000,469 setUp: function() {470 setUrlIndex(2);471 },472 runTest: function() {473 return buildByExpr("Dates > '2015-02-02 23:59:59'");474 }475 }, {476 name: 'dateOperatorIsBetween',477 timeout: 10000,478 setUp: function() {479 setUrlIndex(1);480 },481 runTest: function() {482 return buildByExpr("created_date BETWEEN timestamp '2008-09-06 00:00:00' AND timestamp '2012-06-10 23:59:59'");483 }484 }, {485 name: 'dateOperatorIsBetween-HostedService',486 timeout: 10000,487 setUp: function() {488 setUrlIndex(2);489 },490 runTest: function() {491 return buildByExpr("Dates BETWEEN '2015-02-01 00:00:00' AND '2015-02-02 23:59:59'");492 }493 }, {494 name: 'dateOperatorIsNotBetween',495 timeout: 10000,496 setUp: function() {497 setUrlIndex(1);498 },499 runTest: function() {500 return buildByExpr("created_date NOT BETWEEN timestamp '2008-09-06 00:00:00' AND timestamp '2012-06-10 23:59:59'");501 }502 }, {503 name: 'dateOperatorIsNotBetween-HostedService',504 timeout: 10000,505 setUp: function() {506 setUrlIndex(2);507 },508 runTest: function() {509 return buildByExpr("Dates NOT BETWEEN '2015-02-01 00:00:00' AND '2015-02-02 23:59:59'");510 }511 }, {512 name: 'dateOperatorIsBlank',513 timeout: 10000,514 setUp: function() {515 setUrlIndex(1);516 },517 runTest: function() {518 return buildByExpr("created_date IS NULL");519 }520 }, {521 name: 'dateOperatorIsBlank-HostedService',522 timeout: 10000,523 setUp: function() {524 setUrlIndex(2);525 },526 runTest: function() {527 return buildByExpr("Dates IS NULL");528 }529 }, {530 name: 'dateOperatorIsNotBlank',531 timeout: 10000,532 setUp: function() {533 setUrlIndex(1);534 },535 runTest: function() {536 return buildByExpr("created_date IS NOT NULL");537 }538 }, {539 name: 'dateOperatorIsNotBlank-HostedService',540 timeout: 10000,541 setUp: function() {542 setUrlIndex(2);543 },544 runTest: function() {545 return buildByExpr("Dates IS NOT NULL");546 }547 }, {548 name: 'dateOperatorIsOn-field',549 timeout: 10000,550 setUp: function() {551 setUrlIndex(1);552 },553 runTest: function() {554 return buildByExpr("created_date = last_edited_date");555 }556 }, {557 name: 'dateOperatorIsOn-field-HostedService',558 timeout: 10000,559 setUp: function() {560 setUrlIndex(2);561 },562 runTest: function() {563 return buildByExpr("Dates = CreationDate");564 }565 }, {566 name: 'dateOperatorIsNotOn-field',567 timeout: 10000,568 setUp: function() {569 setUrlIndex(1);570 },571 runTest: function() {572 return buildByExpr("created_date <> last_edited_date");573 }574 }, {575 name: 'dateOperatorIsNotOn-field-HostedService',576 timeout: 10000,577 setUp: function() {578 setUrlIndex(2);579 },580 runTest: function() {581 return buildByExpr("Dates <> CreationDate");582 }583 }, {584 name: 'dateOperatorIsBefore-field',585 timeout: 10000,586 setUp: function() {587 setUrlIndex(1);588 },589 runTest: function() {590 return buildByExpr("created_date < last_edited_date");591 }592 }, {593 name: 'dateOperatorIsBefore-field-HostedService',594 timeout: 10000,595 setUp: function() {596 setUrlIndex(2);597 },598 runTest: function() {599 return buildByExpr("Dates < CreationDate");600 }601 }, {602 name: 'dateOperatorIsAfter-field-HostedService',603 timeout: 10000,604 setUp: function() {605 setUrlIndex(2);606 },607 runTest: function() {608 return buildByExpr("Dates > CreationDate");609 }610 }]);611 doh.run();...
Yahoo.js
Source:Yahoo.js
1dojo.provide("dojox.rpc.tests.Yahoo");2dojo.require("dojo.io.script");3dojo.require("dojox.rpc.Service");4dojox.rpc.tests.yahooService = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary", "yahoo.smd"));5dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT = 8000;6dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT = 30000;7dojox.rpc.tests.yahooService._testMethod = function(method){8 return function(m){9 var d = new doh.Deferred();10 if (method.name && method.parameters && method.expectedResult) {11 var yd = dojox.rpc.tests.yahooService[method.name](method.parameters);12 yd.addCallback(this, function(result){13 if (result[method.expectedResult]){14 d.callback(true);15 }else{16 d.errback(new Error("Unexpected Return Value: ", result));17 }18 });19 }20 return d;21 }22};23doh.register("dojox.rpc.tests.yahoo", 24 [25 {26 name: "#1, Yahoo Answers::questionSearch",27 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,28 runTest: dojox.rpc.tests.yahooService._testMethod({29 name: "questionSearch",30 parameters: {query: "dojo toolkit"},31 expectedResult: "all"32 })33 },34 {35 name: "#2, Yahoo Answers::getByCategory",36 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,37 runTest: dojox.rpc.tests.yahooService._testMethod({38 name: "getByCategory",39 parameters: {category_name: "Computers+%26+Internet%3ESoftware"},40 expectedResult: "all"41 })42 },43 {44 name: "#3, Yahoo Answers::getQuestion",45 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,46 runTest: dojox.rpc.tests.yahooService._testMethod({47 name: "getQuestion",48 parameters: {question_id: "1005120800412"},49 expectedResult: "all"50 })51 },52 {53 name: "#4, Yahoo Answers::getByUser",54 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,55 runTest: dojox.rpc.tests.yahooService._testMethod({56 name: "getByUser",57 parameters: {user_id: "AA10001397"},58 expectedResult: "all"59 })60 },61 {62 name: "#5, Yahoo Audio::artistSearch",63 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,64 runTest: dojox.rpc.tests.yahooService._testMethod({65 name: "artistSearch",66 parameters: {artist: "The Beatles"},67 expectedResult: "ResultSet"68 })69 },70 {71 name: "#6, Yahoo Audio::albumSearch",72 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,73 runTest: dojox.rpc.tests.yahooService._testMethod({74 name: "albumSearch",75 parameters: {artist: "The Beatles", album: "Magical Mystery Tour"},76 expectedResult: "ResultSet"77 })78 },79 {80 name: "#7, Yahoo Audio::songSearch",81 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,82 runTest: dojox.rpc.tests.yahooService._testMethod({83 name: "songSearch",84 parameters: {artist: "The Beatles", album: "Magical Mystery Tour", song: "Penny Lane"},85 expectedResult: "ResultSet"86 })87 },88 {89 name: "#8, Yahoo Audio::songDownloadLocation",90 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,91 runTest: dojox.rpc.tests.yahooService._testMethod({92 name: "songDownloadLocation",93 parameters: {songid: "XXXXXXT000995691"},94 expectedResult: "ResultSet"95 })96 },97 {98 name: "#9, Yahoo ContentAnalysis::contextSearch",99 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,100 runTest: dojox.rpc.tests.yahooService._testMethod({101 name: "contextSearch",102 parameters: {103 context: "Welcome to the Book of Dojo. This book covers both versions 0.9 and 1.0, and all 1.0 extensions and changes are clearly marked for your enjoyment. Please use the forums for support questions, but if you see something missing, incomplete, or just plain wrong in this book, please leave a comment.",104 query: "dojo"105 },106 expectedResult: "ResultSet"107 })108 },109 {110 name: "#10, Yahoo Image::imageSearch",111 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,112 runTest: dojox.rpc.tests.yahooService._testMethod({113 name: "imageSearch",114 parameters: {query: "dojo"},115 expectedResult: "ResultSet"116 })117 },118 {119 name: "#11, Yahoo Local::localSearch",120 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,121 runTest: dojox.rpc.tests.yahooService._testMethod({122 name: "localSearch",123 parameters: {query: "pizza", zip: "98201"},124 expectedResult: "ResultSet"125 })126 },127 {128 name: "#12, Yahoo Local::collectionSearch",129 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,130 runTest: dojox.rpc.tests.yahooService._testMethod({131 name: "collectionSearch",132 parameters: {query: "dojo"},133 expectedResult: "ResultSet"134 })135 },136 {137 name: "#13, Yahoo Local::getCollection",138 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,139 runTest: dojox.rpc.tests.yahooService._testMethod({140 expectedResult: "getCollection",141 parameters: {collection_id: "1000031487"},142 expectedResult: "Result"143 })144 },145 {146 name: "#14, Yahoo Local::trafficData",147 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,148 runTest: dojox.rpc.tests.yahooService._testMethod({149 name: "trafficData",150 parameters: {street: "1600 Pennsylvania Ave", city: "Washington, DC"},151 expectedResult: "ResultSet"152 })153 },154 {155 name: "#15, Yahoo MyWebs::urlSearch",156 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,157 runTest: dojox.rpc.tests.yahooService._testMethod({158 name: "urlSearch",159 parameters: {tag: "javascript"},160 expectedResult: "ResultSet"161 })162 },163 {164 name: "#16, Yahoo MyWebs::tagSearch",165 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,166 runTest: dojox.rpc.tests.yahooService._testMethod({167 name: "tagSearch",168 parameters: {url: "dojotoolkit.org"},169 expectedResult: "ResultSet"170 })171 },172 {173 name: "#17, Yahoo MyWebs::relatedTags",174 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_LONG_TIMEOUT,175 runTest: dojox.rpc.tests.yahooService._testMethod({176 name: "relatedTags",177 parameters: {tag: "javascript"},178 expectedResult: "ResultSet"179 })180 },181 {182 name: "#18, Yahoo NewsSearch::newsSearch",183 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,184 runTest: dojox.rpc.tests.yahooService._testMethod({185 name: "newsSearch",186 parameters: {query: "dojo toolkit"},187 expectedResult: "ResultSet"188 })189 },190 {191 name: "#19, Yahoo Shopping::catalogListing",192 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,193 runTest: dojox.rpc.tests.yahooService._testMethod({194 name: "catalogListing",195 parameters: {idtype: "brand,partnum", idvalue: "canon,1079B001", getspec: 1},196 expectedResult: "Catalog"197 })198 },199 {200 name: "#20, Yahoo Shopping::merchantSearch",201 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,202 runTest: dojox.rpc.tests.yahooService._testMethod({203 name: "merchantSearch",204 parameters: {merchantid: "1021849"},205 expectedResult: "Merchant"206 })207 },208 {209 name: "#21, Yahoo Shopping::productSearch",210 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,211 runTest: dojox.rpc.tests.yahooService._testMethod({212 name: "productSearch",213 parameters: {query: "dojo"},214 expectedResult: "Categories"215 })216 },217 {218 name: "#22, Yahoo SiteExplorer::inlinkData",219 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,220 runTest: dojox.rpc.tests.yahooService._testMethod({221 name: "inlinkData",222 parameters: {query: "dojotoolkit.org"},223 expectedResult: "ResultSet"224 })225 },226 {227 name: "#23, Yahoo SiteExplorer::pageData",228 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,229 runTest: dojox.rpc.tests.yahooService._testMethod({230 name: "pageData",231 parameters: {query: "dojotoolkit.org"},232 expectedResult: "ResultSet"233 })234 },235 {236 name: "#24, Yahoo SiteExplorer::ping",237 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,238 runTest: dojox.rpc.tests.yahooService._testMethod({239 name: "ping",240 parameters: {sitemap: "http://www.yahoo.com"},241 expectedResult: "Success"242 })243 },244 {245 name: "#25, Yahoo SiteExplorer::updateNotification",246 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,247 runTest: dojox.rpc.tests.yahooService._testMethod({248 name: "updateNotification",249 parameters: {url: "http://www.yahoo.com"},250 expectedResult: "Success"251 })252 },253 {254 name: "#26, Yahoo Trip::tripSearch",255 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,256 runTest: dojox.rpc.tests.yahooService._testMethod({257 name: "tripSearch",258 parameters: {query: "eiffel tower"},259 expectedResult: "ResultSet"260 })261 },262 {263 name: "#27, Yahoo Trip::getTrip",264 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,265 runTest: dojox.rpc.tests.yahooService._testMethod({266 name: "getTrip",267 parameters: {id: "546303"},268 expectedResult: "Result"269 })270 },271 {272 name: "#28, Yahoo Video::videoSearch",273 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,274 runTest: dojox.rpc.tests.yahooService._testMethod({275 name: "videoSearch",276 parameters: {query: "star wars kid"},277 expectedResult: "ResultSet"278 })279 },280 {281 name: "#29, Yahoo Web::webSearch",282 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,283 runTest: dojox.rpc.tests.yahooService._testMethod({284 name: "webSearch",285 parameters: {query: "dojo toolkit"},286 expectedResult: "ResultSet"287 })288 },289 {290 name: "#30, Yahoo Web::spellingSuggestion",291 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,292 runTest: dojox.rpc.tests.yahooService._testMethod({293 name: "spellingSuggestion",294 parameters: {query: "beatls"},295 expectedResult: "ResultSet"296 })297 },298 {299 name: "#31, Yahoo Web::relatedSuggestion",300 timeout: dojox.rpc.tests.yahooService.TEST_METHOD_TIMEOUT,301 runTest: dojox.rpc.tests.yahooService._testMethod({302 name: "relatedSuggestion",303 parameters: {query: "dojo toolkit"},304 expectedResult: "ResultSet"305 })306 }...
hash.js
Source:hash.js
1dojo.provide("tests.hash");2dojo.require("dojo.hash");3(function(){4// utilities for the tests:5 function setHash(h){6 h = h || "";7 location.replace('#'+h);8 }9 10 function getHash(){11 var h = location.href, i = h.indexOf("#");12 return (i >= 0) ? h.substring(i + 1) : "";13 }14 tests.register("tests.hash", [15 // hash as an empty string.16 {17 name: "Getting an empty hash",18 setUp: function(){19 setHash();20 },21 runTest: function(t){22 t.is('', dojo.hash());23 }24 },25 {26 name: "Setting an empty hash",27 setUp: function(){28 dojo.hash('');29 },30 runTest: function(t){31 t.is('', getHash());32 }33 },34 // hash as "test"35 {36 name: "Getting the hash of 'test'",37 setUp: function(){38 setHash('test');39 },40 runTest: function(t){41 t.is('test', dojo.hash());42 },43 tearDown: function(){44 setHash();45 }46 },47 {48 name: "Setting the hash to 'test'",49 setUp: function(){50 dojo.hash('test');51 },52 runTest: function(t){53 t.is('test', getHash());54 },55 tearDown: function(){56 setHash();57 }58 },59 // hash with spaces60 {61 name: "Getting the hash of 'test%20with%20spaces'",62 setUp: function(){63 setHash('test%20with%20spaces');64 },65 runTest: function(t){66 t.is('test%20with%20spaces', dojo.hash());67 },68 tearDown: function(){69 setHash();70 }71 },72 {73 name: "Setting the hash of 'test%20with%20spaces'",74 setUp: function(){75 setHash('test%20with%20spaces');76 },77 runTest: function(t){78 t.is('test%20with%20spaces', getHash());79 },80 tearDown: function(){81 setHash();82 }83 },84 // hash with encoded hash85 {86 name: "Getting the hash of 'test%23with%23encoded%23hashes'",87 setUp: function(){88 setHash('test%23with%23encoded%23hashes');89 },90 runTest: function(t){91 t.is('test%23with%23encoded%23hashes', dojo.hash());92 },93 tearDown: function(){94 setHash();95 }96 },97 {98 name: "Setting the hash of 'test%23with%23encoded%23hashes'",99 setUp: function(){100 setHash('test%23with%23encoded%23hashes');101 },102 runTest: function(t){103 t.is('test%23with%23encoded%23hashes', getHash());104 },105 tearDown: function(){106 setHash();107 }108 },109 // hash with plus character: test+with+pluses110 {111 name: "Getting the hash of 'test+with+pluses'",112 setUp: function(){113 setHash('test+with+pluses');114 },115 runTest: function(t){116 t.is('test+with+pluses', dojo.hash());117 },118 tearDown: function(){119 setHash();120 }121 },122 {123 name: "Setting the hash to 'test+with+pluses'",124 setUp: function(){125 dojo.hash('test+with+pluses');126 },127 runTest: function(t){128 t.is('test+with+pluses', getHash());129 },130 tearDown: function(){131 setHash();132 }133 },134 // hash with leading space135 {136 name: "Getting the hash of '%20leadingSpace'",137 setUp: function(){138 setHash('%20leadingSpace');139 },140 runTest: function(t){141 t.is('%20leadingSpace', dojo.hash());142 },143 tearDown: function(){144 setHash();145 }146 },147 {148 name: "Setting the hash to '%20leadingSpace'",149 setUp: function(){150 dojo.hash('%20leadingSpace');151 },152 runTest: function(t){153 t.is('%20leadingSpace', getHash());154 },155 tearDown: function(){156 setHash();157 }158 },159 160 // hash with trailing space:161 {162 name: "Getting the hash of 'trailingSpace%20'",163 setUp: function(){164 setHash('trailingSpace%20');165 },166 runTest: function(t){167 t.is('trailingSpace%20', dojo.hash());168 },169 tearDown: function(){170 setHash();171 }172 },173 {174 name: "Setting the hash to 'trailingSpace%20'",175 setUp: function(){176 dojo.hash('trailingSpace%20');177 },178 runTest: function(t){179 t.is('trailingSpace%20', getHash());180 },181 tearDown: function(){182 setHash();183 }184 },185 // hash with underscores.186 {187 name: "Getting the hash of 'under_score'",188 setUp: function(){189 setHash('under_score');190 },191 runTest: function(t){192 t.is('under_score', dojo.hash());193 },194 tearDown: function(){195 setHash();196 }197 },198 {199 name: "Setting the hash to 'under_score'",200 setUp: function(){201 dojo.hash('under_score');202 },203 runTest: function(t){204 t.is('under_score', getHash());205 },206 tearDown: function(){207 setHash();208 }209 },210 {211 name: "Getting the hash of 'extra&instring'",212 setUp: function(){213 setHash("extra&instring");214 },215 runTest: function(t){216 t.is("extra&instring", dojo.hash());217 },218 tearDown: function(){219 setHash();220 }221 },222 {223 name: "Setting the hash to 'extra&instring'",224 setUp: function(){225 dojo.hash('extra&instring');226 },227 runTest: function(t){228 t.is('extra&instring', getHash());229 },230 tearDown: function(){231 setHash();232 }233 },234 {235 name: "Getting the hash of 'extra?instring'",236 setUp: function(){237 setHash('extra?instring');238 },239 runTest: function(t){240 t.is('extra?instring', dojo.hash());241 },242 tearDown: function(){243 setHash();244 }245 },246 {247 name: "Setting the hash of 'extra?instring'",248 setUp: function(){249 dojo.hash('extra?instring');250 },251 runTest: function(t){252 t.is('extra?instring', getHash());253 },254 tearDown: function(){255 setHash();256 }257 },258 {259 name: "Getting the hash resembling a query parameter ('?testa=3&testb=test')",260 setUp: function(){261 setHash('?testa=3&testb=test');262 },263 runTest: function(t){264 t.is('?testa=3&testb=test', dojo.hash());265 },266 tearDown: function(){267 setHash();268 }269 },270 {271 name: "Setting the hash resembling a query parameter ('?testa=3&testb=test')",272 setUp: function(){273 dojo.hash('?testa=3&testb=test');274 },275 runTest: function(t){276 t.is('?testa=3&testb=test', getHash());277 },278 tearDown: function(){279 setHash();280 }281 },282 {283 name: "Setting the hash to '#leadingHash' should result in the hash being 'leadingHash'",284 setUp: function(){285 dojo.hash('#leadingHash');286 },287 runTest: function(t){288 t.is('leadingHash', getHash());289 },290 tearDown: function(){291 setHash();292 }293 },294 {295 _s: null, // used for the subscriber.296 297 name: "Hash change publishes to '/dojo/hashchange'",298 setUp: function(t){299 setHash();300 },301 runTest: function(t){302 var d = new doh.Deferred();303 this._s = dojo.subscribe('/dojo/hashchange', null, function(value){304 try {305 doh.assertEqual('test', value);306 d.callback(true);307 } catch(e){308 d.errback(e);309 }310 });311 312 dojo.hash('test');313 return d;314 },315 tearDown: function(){316 dojo.unsubscribe(this._s);317 setHash();318 }319 } 320 ]);...
regress-164697.js
Source:regress-164697.js
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */2/* ***** BEGIN LICENSE BLOCK *****3 * Version: MPL 1.1/GPL 2.0/LGPL 2.14 *5 * The contents of this file are subject to the Mozilla Public License Version6 * 1.1 (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * http://www.mozilla.org/MPL/9 *10 * Software distributed under the License is distributed on an "AS IS" basis,11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License12 * for the specific language governing rights and limitations under the13 * License.14 *15 * The Original Code is JavaScript Engine testing utilities.16 *17 * The Initial Developer of the Original Code is18 * Mozilla Foundation.19 * Portions created by the Initial Developer are Copyright (C) 200520 * the Initial Developer. All Rights Reserved.21 *22 * Contributor(s): Brendan Eich23 *24 * Alternatively, the contents of this file may be used under the terms of25 * either the GNU General Public License Version 2 or later (the "GPL"), or26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),27 * in which case the provisions of the GPL or the LGPL are applicable instead28 * of those above. If you wish to allow use of your version of this file only29 * under the terms of either the GPL or the LGPL, and not to allow others to30 * use your version of this file under the terms of the MPL, indicate your31 * decision by deleting the provisions above and replace them with the notice32 * and other provisions required by the GPL or the LGPL. If you do not delete33 * the provisions above, a recipient may use your version of this file under34 * the terms of any one of the MPL, the GPL or the LGPL.35 *36 * ***** END LICENSE BLOCK ***** */37var gTestfile = 'regress-164697.js';38//-----------------------------------------------------------------------------39var BUGNUMBER = 164697;40var summary = '(instance.__parent__ == constructor.__parent__)';41var actual = '';42var expect = '';43printBugNumber(BUGNUMBER);44printStatus (summary);45expect = 'true';46runtest('{}', 'Object');47runtest('new Object()', 'Object');48// see https://bugzilla.mozilla.org/show_bug.cgi?id=32166949// for why this test is not contained in a function.50actual = (function (){}).__proto__ == Function.prototype;51reportCompare('true', actual+'',52 '(function (){}).__proto__ == Function.prototype');53runtest('new Function(";")', 'Function');54runtest('[]', 'Array');55runtest('new Array()', 'Array');56runtest('""', 'String');57runtest('new String()', 'String');58runtest('true', 'Boolean');59runtest('new Boolean()', 'Boolean');60runtest('1', 'Number');61runtest('new Number("1")', 'Number');62runtest('new Date()', 'Date');63runtest('/x/', 'RegExp');64runtest('new RegExp("x")', 'RegExp');65runtest('new Error()', 'Error');66function runtest(myinstance, myconstructor)67{68 var expr;69 var actual;70 try71 {72 expr = '(' + myinstance + ').__parent__ == ' +73 myconstructor + '.__parent__';74 printStatus(expr);75 actual = eval(expr).toString();76 }77 catch(ex)78 {79 actual = ex + '';80 }81 reportCompare(expect, actual, expr);82 try83 {84 expr = '(' + myinstance + ').__proto__ == ' +85 myconstructor + '.prototype';86 printStatus(expr);87 actual = eval(expr).toString();88 }89 catch(ex)90 {91 actual = ex + '';92 }93 reportCompare(expect, actual, expr);...
fixtures.js
Source:fixtures.js
...47 }48 });49 atoe(ee, events);50}51function runTest(name, opts) {52 opts = opts || {};53 (opts.debug ? test.only : test)(name, t => {54 const events = JSON.parse(loadFixture(name + '.json'));55 const expected = tryLoad(name + '.tap-out', name + '.tap').trim();56 const lines = [];57 processEvents(events, lines, 0, opts);58 const output = lines.join('\n').trim();59 if (opts.debug) {60 console.log(output);61 if (output !== expected) {62 console.log(disparity.unified(expected, output));63 }64 } else {65 t.is(output, expected);66 }67 });68}69runTest('bailout');70runTest('basic', {id: false});71runTest('bignum');72runTest('bignum_many');73runTest('broken-yamlish-looks-like-child');74runTest('child-extra');75runTest('combined');76runTest('combined_compat');77runTest('comment-mid-diag');78runTest('comment-mid-diag-postplan');79runTest('common-with-explanation');80runTest('creative-liberties');81runTest('delayed');82runTest('descriptive');83runTest('descriptive_trailing');84runTest('die_head_end');85runTest('die_last_minute');86runTest('die_unfinished');87runTest('duplicates');88runTest('echo');89runTest('empty');90runTest('escape_eol');91runTest('escape_hash');92runTest('extra-in-child');93runTest('garbage-yamlish');94runTest('giving-up');95runTest('got-spare-tuits');96runTest('head_end');97runTest('head_fail');98runTest('implicit-counter', {id: false});99runTest('indent');100runTest('indented-stdout-noise');101runTest('junk_before_plan');102runTest('line-break');...
run-all.js
Source:run-all.js
...20 * DEALINGS IN THE SOFTWARE.21 *22 * Created by Cristian-Alexandru Staicu on 28.07.17.23 */24runTest("./test-ajv");25runTest("./test-charset");26runTest("./test-content");27runTest("./test-content-type-parser");28runTest("./test-debug");29runTest("./test-dns-sync");30runTest("./test-fresh");31runTest("./test-forwarded");32runTest("./test-htmlparser");33runTest("./test-ismobilejs");34runTest("./test-lodash");35runTest("./test-marked");36runTest("./test-mime");37runTest("./test-mobile-detect");38runTest("./test-moment");39runTest("./test-no-case");40runTest("./test-parsejson");41runTest("./test-platform");42runTest("./test-slug");43runTest("./test-string");44runTest("./test-though-cookie");45runTest("./test-timespan");46runTest("./test-underscore-string");47function runTest(fctName) {48 console.log("Running test " + fctName);49 require(fctName);...
Using AI Code Generation
1var wd = require('wd');2var driver = wd.remote("localhost", 4723);3driver.init({4}, function() {5 driver.runTest("path/to/your_test.js", function(err) {6 if (err) {7 console.log(err);8 }9 driver.quit();10 });11});12var wd = require('wd');13var driver = wd.remote("localhost", 4723);14driver.init({15}, function() {16 driver.elementByClassName('android.widget.EditText', function(err, el) {17 el.sendKeys("Hello World!", function(err) {18 driver.quit();19 });20 });21});
Using AI Code Generation
1var AppiumAndroidDriver = require('appium-android-driver');2AppiumAndroidDriver.runTest('test.js');3var AppiumiOSDriver = require('appium-ios-driver');4AppiumiOSDriver.runTest('test.js');5var AppiumWindowsDriver = require('appium-windows-driver');6AppiumWindowsDriver.runTest('test.js');7var AppiumMacDriver = require('appium-mac-driver');8AppiumMacDriver.runTest('test.js');9var AppiumWebdriver = require('appium-webdriver');10AppiumWebdriver.runTest('test.js');11var AppiumYouiEngineDriver = require('appium-youiengine-driver');12AppiumYouiEngineDriver.runTest('test.js');13var AppiumTizenDriver = require('appium-tizen-driver');14AppiumTizenDriver.runTest('test.js');15var AppiumFireOSDriver = require('appium-fireos-driver');16AppiumFireOSDriver.runTest('test.js');17var AppiumAndroidDriver = require('appium-android-driver');18AppiumAndroidDriver.runTest('test.js');19var AppiumAndroidDriver = require('appium-android-driver');20AppiumAndroidDriver.runTest('test.js');21var AppiumAndroidDriver = require('appium-android-driver');22AppiumAndroidDriver.runTest('test.js');23var AppiumAndroidDriver = require('appium-android-driver');24AppiumAndroidDriver.runTest('test.js');25var AppiumAndroidDriver = require('appium-android-driver');26AppiumAndroidDriver.runTest('test.js');27var AppiumAndroidDriver = require('appium-android-driver');
Using AI Code Generation
1var wd = require('wd');2var desired = {3};4var driver = wd.remote('localhost', 4723);5driver.init(desired, function() {6 driver.runTest('test', function(err) {7 console.log(err);8 driver.quit();9 });10});11var wd = require('wd');12var desired = {13};14var driver = wd.remote('localhost', 4723);15driver.init(desired, function() {16 driver.runTest('test', function(err) {17 console.log(err);18 driver.quit();19 });20});21var wd = require('wd');22var desired = {23};24var driver = wd.remote('localhost', 4723);25driver.init(desired, function() {26 driver.runTest('test', function(err) {27 console.log(err);28 driver.quit();29 });30});31var wd = require('wd');32var desired = {33};34var driver = wd.remote('localhost', 4723);35driver.init(desired, function() {36 driver.runTest('test', function(err) {37 console.log(err);38 driver.quit();39 });40});
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var fs = require('fs');4var path = require('path');5var desired = {6 app: path.resolve(__dirname, 'TestApp.apk'),7};8var driver = wd.remote("localhost", 4723);9driver.init(desired, function(err) {10 if (err) {11 console.error(err);12 return;13 }14 driver.runTest("com.example.android.contactmanager.tests.ContactManagerTest", "testAddContact", function(err, res) {15 if (err) {16 console.error(err);17 return;18 }19 console.log("Test result: " + res);20 driver.quit();21 });22});
Using AI Code Generation
1var wd = require('wd');2var AndroidDriver = require('appium-android-driver');3var driver = wd.promiseChainRemote();4driver.init({5}).then(function() {6 return driver.runTest('/path/to/test.js', 'com.example.mytestapp', 'MyTestAppTest');7}).then(function() {8 return driver.quit();9}).done();10var wd = require('wd');11var AndroidDriver = require('appium-android-driver');12var driver = wd.promiseChainRemote();13driver.init({14}).then(function() {15 return driver.runTest('/path/to/test.js', 'com.example.mytestapp', 'MyTestAppTest');16}).then(function() {17 return driver.quit();18}).done();
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var desired = require('./desired');4var AndroidDriver = require('appium-android-driver');5var driver = wd.promiseChainRemote('localhost', 4723);6desired.appPackage = 'io.appium.TestApp';7desired.appActivity = '.SplashActivity';8 .init(desired)9 .then(function () {10 var androidDriver = new AndroidDriver();11 androidDriver.runTest('io.appium.TestApp', 'exampleInstrumentationTest', 'testPasses');12 })13 .fin(function () { return driver.quit(); })14 .done();15module.exports = {16};17var wd = require('wd');18var assert = require('assert');19var desired = require('./desired');20var driver = wd.promiseChainRemote('localhost', 4723);21desired.appPackage = 'io.appium.TestApp';22desired.appActivity = '.SplashActivity';23 .init(desired)24 .sleep(5000)25 .elementByAccessibilityId('ComputeSumButton')26 .click()27 .sendKeys('2')28 .sendKeys('3')29 .elementByAccessibilityId('Done')30 .click()31 .text().should.become('5')32 .fin(function () { return driver
Using AI Code Generation
1describe('Appium Android Driver', function() {2 this.timeout(600000);3 it('should run test', function(done) {4 var appiumAndroidDriver = new AppiumAndroidDriver();5 appiumAndroidDriver.runTest('test1', done);6 });7});8var AppiumAndroidDriver = function() {};9AppiumAndroidDriver.prototype.runTest = function(testName, done) {10 var appium = require('appium');11 var server = appium.main('appium.js', {logNoColors: true});12 server.on('error', function (err) {13 console.log('Error: ' + err);14 done();15 });16 server.on('listening', function () {17 console.log('Server is listening');18 done();19 });20};21module.exports = AppiumAndroidDriver;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!