How to use view2 method in wpt

Best JavaScript code snippet using wpt

data1.js

Source:data1.js Github

copy

Full Screen

1export default {2 "seller": {3 "name": "粥品香坊(回龙观)",4 "description": "蜂鸟专送",5 "deliveryTime": 38,6 "score": 4.2,7 "serviceScore": 4.1,8 "foodScore": 4.3,9 "rankRate": 69.2,10 "minPrice": 20,11 "deliveryPrice": 4,12 "ratingCount": 24,13 "sellCount": 90,14 "bulletin": "粥品香坊其烹饪粥料的秘方源于中国千年古法,在融和现代制作工艺,由世界烹饪大师屈浩先生领衔研发。坚守纯天然、0添加的良心品质深得消费者青睐,发展至今成为粥类的引领品牌。是2008年奥运会和2013年园博会指定餐饮服务商。",15 "supports": [16 {17 "type": 0,18 "description": "在线支付满28减5"19 },20 {21 "type": 1,22 "description": "VC无限橙果汁全场8折"23 },24 {25 "type": 2,26 "description": "单人精彩套餐"27 },28 {29 "type": 3,30 "description": "该商家支持发票,请下单写好发票抬头"31 },32 {33 "type": 4,34 "description": "已加入“外卖保”计划,食品安全保障"35 }36 ],37 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/seller_avatar_256px.jpg",38 "pics": [39 "http://fuss10.elemecdn.com/8/71/c5cf5715740998d5040dda6e66abfjpeg.jpeg?imageView2/1/w/180/h/180",40 "http://fuss10.elemecdn.com/b/6c/75bd250e5ba69868f3b1178afbda3jpeg.jpeg?imageView2/1/w/180/h/180",41 "http://fuss10.elemecdn.com/f/96/3d608c5811bc2d902fc9ab9a5baa7jpeg.jpeg?imageView2/1/w/180/h/180",42 "http://fuss10.elemecdn.com/6/ad/779f8620ff49f701cd4c58f6448b6jpeg.jpeg?imageView2/1/w/180/h/180"43 ],44 "infos": [45 "该商家支持发票,请下单写好发票抬头",46 "品类:其他菜系,包子粥店",47 "北京市昌平区回龙观西大街龙观置业大厦底商B座102单元1340",48 "营业时间:10:00-20:30"49 ]50 },51 "goods": [52 {53 "name": "热销榜",54 "type": -1,55 "foods": [56 {57 "name": "皮蛋瘦肉粥",58 "price": 10,59 "oldPrice": 14,60 "description": "咸粥",61 "sellCount": 229,62 "rating": 100,63 "info": "一碗皮蛋瘦肉粥,总是我到粥店时的不二之选。香浓软滑,饱腹暖心,皮蛋的Q弹与瘦肉的滑嫩伴着粥香溢于满口,让人喝这样的一碗粥也觉得心满意足",64 "ratings": [65 {66 "username": "3******c",67 "rateTime": 1469281964000,68 "rateType": 0,69 "text": "很喜欢的粥",70 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"71 },72 {73 "username": "2******3",74 "rateTime": 1469271264000,75 "rateType": 0,76 "text": "",77 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"78 },79 {80 "username": "3******b",81 "rateTime": 1469261964000,82 "rateType": 1,83 "text": "",84 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"85 }86 ],87 "icon": "http://fuss10.elemecdn.com/c/cd/c12745ed8a5171e13b427dbc39401jpeg.jpeg?imageView2/1/w/114/h/114",88 "image": "http://fuss10.elemecdn.com/c/cd/c12745ed8a5171e13b427dbc39401jpeg.jpeg?imageView2/1/w/750/h/750"89 },90 {91 "name": "扁豆焖面",92 "price": 14,93 "oldPrice": "",94 "description": "",95 "sellCount": 188,96 "rating": 96,97 "ratings": [98 {99 "username": "3******c",100 "rateTime": 1469281964000,101 "rateType": 0,102 "text": "",103 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"104 },105 {106 "username": "2******3",107 "rateTime": 1469271264000,108 "rateType": 0,109 "text": "",110 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"111 },112 {113 "username": "3******b",114 "rateTime": 1469261964000,115 "rateType": 1,116 "text": "",117 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"118 }119 ],120 "info": "",121 "icon": "http://fuss10.elemecdn.com/c/6b/29e3d29b0db63d36f7c500bca31d8jpeg.jpeg?imageView2/1/w/114/h/114",122 "image": "http://fuss10.elemecdn.com/c/6b/29e3d29b0db63d36f7c500bca31d8jpeg.jpeg?imageView2/1/w/750/h/750"123 },124 {125 "name": "葱花饼",126 "price": 10,127 "oldPrice": "",128 "description": "",129 "sellCount": 124,130 "rating": 85,131 "info": "",132 "ratings": [133 {134 "username": "3******c",135 "rateTime": 1469281964000,136 "rateType": 1,137 "text": "没啥味道",138 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"139 },140 {141 "username": "2******3",142 "rateTime": 1469271264000,143 "rateType": 1,144 "text": "很一般啊",145 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"146 },147 {148 "username": "3******b",149 "rateTime": 1469261964000,150 "rateType": 0,151 "text": "",152 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"153 }154 ],155 "icon": "http://fuss10.elemecdn.com/f/28/a51e7b18751bcdf871648a23fd3b4jpeg.jpeg?imageView2/1/w/114/h/114",156 "image": "http://fuss10.elemecdn.com/f/28/a51e7b18751bcdf871648a23fd3b4jpeg.jpeg?imageView2/1/w/750/h/750"157 },158 {159 "name": "牛肉馅饼",160 "price": 14,161 "oldPrice": "",162 "description": "",163 "sellCount": 114,164 "rating": 91,165 "info": "",166 "ratings": [167 {168 "username": "3******c",169 "rateTime": 1469281964000,170 "rateType": 1,171 "text": "难吃不推荐",172 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"173 },174 {175 "username": "2******3",176 "rateTime": 1469271264000,177 "rateType": 0,178 "text": "",179 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"180 },181 {182 "username": "3******b",183 "rateTime": 1469261964000,184 "rateType": 0,185 "text": "",186 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"187 }188 ],189 "icon": "http://fuss10.elemecdn.com/d/b9/bcab0e8ad97758e65ae5a62b2664ejpeg.jpeg?imageView2/1/w/114/h/114",190 "image": "http://fuss10.elemecdn.com/d/b9/bcab0e8ad97758e65ae5a62b2664ejpeg.jpeg?imageView2/1/w/750/h/750"191 },192 {193 "name": "招牌猪肉白菜锅贴/10个",194 "price": 17,195 "oldPrice": "",196 "description": "",197 "sellCount": 101,198 "rating": 78,199 "info": "",200 "ratings": [201 {202 "username": "3******c",203 "rateTime": 1469281964000,204 "rateType": 1,205 "text": "不脆,不好吃",206 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"207 },208 {209 "username": "2******3",210 "rateTime": 1469271264000,211 "rateType": 0,212 "text": "",213 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"214 },215 {216 "username": "3******b",217 "rateTime": 1469261964000,218 "rateType": 0,219 "text": "",220 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"221 }222 ],223 "icon": "http://fuss10.elemecdn.com/7/72/9a580c1462ca1e4d3c07e112bc035jpeg.jpeg?imageView2/1/w/114/h/114",224 "image": "http://fuss10.elemecdn.com/7/72/9a580c1462ca1e4d3c07e112bc035jpeg.jpeg?imageView2/1/w/750/h/750"225 },226 {227 "name": "南瓜粥",228 "price": 9,229 "oldPrice": "",230 "description": "甜粥",231 "sellCount": 91,232 "rating": 100,233 "ratings": [234 {235 "username": "3******c",236 "rateTime": 1469281964000,237 "rateType": 0,238 "text": "",239 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"240 },241 {242 "username": "2******3",243 "rateTime": 1469271264000,244 "rateType": 0,245 "text": "",246 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"247 },248 {249 "username": "3******b",250 "rateTime": 1469261964000,251 "rateType": 0,252 "text": "",253 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"254 }255 ],256 "icon": "http://fuss10.elemecdn.com/8/a6/453f65f16b1391942af11511b7a90jpeg.jpeg?imageView2/1/w/114/h/114",257 "image": "http://fuss10.elemecdn.com/8/a6/453f65f16b1391942af11511b7a90jpeg.jpeg?imageView2/1/w/750/h/750"258 },259 {260 "name": "红豆薏米美肤粥",261 "price": 12,262 "oldPrice": "",263 "description": "甜粥",264 "sellCount": 86,265 "rating": 100,266 "info": "",267 "ratings": [268 {269 "username": "3******c",270 "rateTime": 1469281964000,271 "rateType": 0,272 "text": "",273 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"274 },275 {276 "username": "2******3",277 "rateTime": 1469271264000,278 "rateType": 0,279 "text": "",280 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"281 },282 {283 "username": "3******b",284 "rateTime": 1469261964000,285 "rateType": 0,286 "text": "",287 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"288 }289 ],290 "icon": "http://fuss10.elemecdn.com/d/22/260bd78ee6ac6051136c5447fe307jpeg.jpeg?imageView2/1/w/114/h/114",291 "image": "http://fuss10.elemecdn.com/d/22/260bd78ee6ac6051136c5447fe307jpeg.jpeg?imageView2/1/w/750/h/750"292 },293 {294 "name": "八宝酱菜",295 "price": 4,296 "oldPrice": "",297 "description": "",298 "sellCount": 84,299 "rating": 100,300 "info": "",301 "ratings": [302 {303 "username": "3******c",304 "rateTime": 1469281964000,305 "rateType": 0,306 "text": "",307 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"308 },309 {310 "username": "2******3",311 "rateTime": 1469271264000,312 "rateType": 0,313 "text": "",314 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"315 },316 {317 "username": "3******b",318 "rateTime": 1469261964000,319 "rateType": 0,320 "text": "",321 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"322 }323 ],324 "icon": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114",325 "image": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/750/h/750"326 },327 {328 "name": "红枣山药糙米粥",329 "price": 10,330 "oldPrice": "",331 "description": "",332 "sellCount": 81,333 "rating": 91,334 "info": "",335 "ratings": [336 {337 "username": "3******c",338 "rateTime": 1469281964000,339 "rateType": 0,340 "text": "",341 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"342 },343 {344 "username": "2******3",345 "rateTime": 1469271264000,346 "rateType": 0,347 "text": "",348 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"349 },350 {351 "username": "3******b",352 "rateTime": 1469261964000,353 "rateType": 0,354 "text": "",355 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"356 }357 ],358 "icon": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114",359 "image": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/750/h/750"360 },361 {362 "name": "糊塌子",363 "price": 10,364 "oldPrice": "",365 "description": "",366 "sellCount": 80,367 "rating": 93,368 "info": "",369 "ratings": [370 {371 "username": "3******c",372 "rateTime": 1469281964000,373 "rateType": 0,374 "text": "",375 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"376 },377 {378 "username": "2******3",379 "rateTime": 1469271264000,380 "rateType": 0,381 "text": "",382 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"383 },384 {385 "username": "3******b",386 "rateTime": 1469261964000,387 "rateType": 0,388 "text": "",389 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"390 }391 ],392 "icon": "http://fuss10.elemecdn.com/0/05/097a2a59fd2a2292d08067e16380cjpeg.jpeg?imageView2/1/w/114/h/114",393 "image": "http://fuss10.elemecdn.com/0/05/097a2a59fd2a2292d08067e16380cjpeg.jpeg?imageView2/1/w/750/h/750"394 }395 ]396 },397 {398 "name": "单人精彩套餐",399 "type": 2,400 "foods": [401 {402 "name": "红枣山药粥套餐",403 "price": 29,404 "oldPrice": 36,405 "description": "红枣山药糙米粥,素材包,爽口莴笋丝,四川泡菜或八宝酱菜,配菜可备注",406 "sellCount": 17,407 "rating": 100,408 "info": "",409 "ratings": [410 {411 "username": "2******3",412 "rateTime": 1469271264000,413 "rateType": 0,414 "text": "",415 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"416 }417 ],418 "icon": "http://fuss10.elemecdn.com/6/72/cb844f0bb60c502c6d5c05e0bddf5jpeg.jpeg?imageView2/1/w/114/h/114",419 "image": "http://fuss10.elemecdn.com/6/72/cb844f0bb60c502c6d5c05e0bddf5jpeg.jpeg?imageView2/1/w/750/h/750"420 }421 ]422 },423 {424 "name": "冰爽饮品限时特惠",425 "type": 1,426 "foods": [427 {428 "name": "VC无限橙果汁",429 "price": 8,430 "oldPrice": 10,431 "description": "",432 "sellCount": 15,433 "rating": 100,434 "info": "",435 "ratings": [436 {437 "username": "3******c",438 "rateTime": 1469281964000,439 "rateType": 0,440 "text": "还可以",441 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"442 },443 {444 "username": "2******3",445 "rateTime": 1469271264000,446 "rateType": 0,447 "text": "",448 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"449 }450 ],451 "icon": "http://fuss10.elemecdn.com/e/c6/f348e811772016ae24e968238bcbfjpeg.jpeg?imageView2/1/w/114/h/114",452 "image": "http://fuss10.elemecdn.com/e/c6/f348e811772016ae24e968238bcbfjpeg.jpeg?imageView2/1/w/750/h/750"453 }454 ]455 },456 {457 "name": "精选热菜",458 "type": -1,459 "foods": [460 {461 "name": "娃娃菜炖豆腐",462 "price": 17,463 "oldPrice": "",464 "description": "",465 "sellCount": 43,466 "rating": 92,467 "info": "",468 "ratings": [469 {470 "username": "3******c",471 "rateTime": 1469281964000,472 "rateType": 0,473 "text": "菜量还可以,味道还可以",474 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"475 },476 {477 "username": "2******3",478 "rateTime": 1469271264000,479 "rateType": 0,480 "text": "",481 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"482 }483 ],484 "icon": "http://fuss10.elemecdn.com/d/2d/b1eb45b305635d9dd04ddf157165fjpeg.jpeg?imageView2/1/w/114/h/114",485 "image": "http://fuss10.elemecdn.com/d/2d/b1eb45b305635d9dd04ddf157165fjpeg.jpeg?imageView2/1/w/750/h/750"486 },487 {488 "name": "手撕包菜",489 "price": 16,490 "oldPrice": "",491 "description": "",492 "sellCount": 29,493 "rating": 100,494 "info": "",495 "ratings": [496 {497 "username": "3******c",498 "rateTime": 1469281964000,499 "rateType": 0,500 "text": "",501 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"502 },503 {504 "username": "2******3",505 "rateTime": 1469271264000,506 "rateType": 0,507 "text": "",508 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"509 }510 ],511 "icon": "http://fuss10.elemecdn.com/9/c6/f3bc84468820121112e79583c24efjpeg.jpeg?imageView2/1/w/114/h/114",512 "image": "http://fuss10.elemecdn.com/9/c6/f3bc84468820121112e79583c24efjpeg.jpeg?imageView2/1/w/750/h/750"513 },514 {515 "name": "香酥黄金鱼/3条",516 "price": 11,517 "oldPrice": "",518 "description": "",519 "sellCount": 15,520 "rating": 100,521 "info": "",522 "ratings": [523 {524 "username": "3******c",525 "rateTime": 1469281964000,526 "rateType": 0,527 "text": "",528 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"529 },530 {531 "username": "2******3",532 "rateTime": 1469271264000,533 "rateType": 0,534 "text": "",535 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"536 }537 ],538 "icon": "http://fuss10.elemecdn.com/4/e7/8277a6a2ea0a2e97710290499fc41jpeg.jpeg?imageView2/1/w/114/h/114",539 "image": "http://fuss10.elemecdn.com/4/e7/8277a6a2ea0a2e97710290499fc41jpeg.jpeg?imageView2/1/w/750/h/750"540 }541 ]542 },543 {544 "name": "爽口凉菜",545 "type": -1,546 "foods": [547 {548 "name": "八宝酱菜",549 "price": 4,550 "oldPrice": "",551 "description": "",552 "sellCount": 84,553 "rating": 100,554 "info": "",555 "ratings": [556 {557 "username": "3******c",558 "rateTime": 1469281964000,559 "rateType": 0,560 "text": "",561 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"562 },563 {564 "username": "2******3",565 "rateTime": 1469271264000,566 "rateType": 0,567 "text": "",568 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"569 },570 {571 "username": "3******b",572 "rateTime": 1469261964000,573 "rateType": 0,574 "text": "",575 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"576 }577 ],578 "icon": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114",579 "image": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/750/h/750"580 },581 {582 "name": "拍黄瓜",583 "price": 9,584 "oldPrice": "",585 "description": "",586 "sellCount": 28,587 "rating": 100,588 "info": "",589 "ratings": [590 {591 "username": "3******c",592 "rateTime": 1469281964000,593 "rateType": 0,594 "text": "",595 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"596 },597 {598 "username": "2******3",599 "rateTime": 1469271264000,600 "rateType": 0,601 "text": "",602 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"603 },604 {605 "username": "3******b",606 "rateTime": 1469261964000,607 "rateType": 0,608 "text": "",609 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"610 }611 ],612 "icon": "http://fuss10.elemecdn.com/6/54/f654985b4e185f06eb07f8fa2b2e8jpeg.jpeg?imageView2/1/w/114/h/114",613 "image": "http://fuss10.elemecdn.com/6/54/f654985b4e185f06eb07f8fa2b2e8jpeg.jpeg?imageView2/1/w/750/h/750"614 }615 ]616 },617 {618 "name": "精选套餐",619 "type": -1,620 "foods": [621 {622 "name": "红豆薏米粥套餐",623 "price": 37,624 "oldPrice": "",625 "description": "红豆薏米粥,三鲜干蒸烧卖,拍黄瓜",626 "sellCount": 3,627 "rating": 100,628 "info": "",629 "ratings": [630 {631 "username": "2******3",632 "rateTime": 1469271264000,633 "rateType": 0,634 "text": "",635 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"636 }637 ],638 "icon": "http://fuss10.elemecdn.com/f/49/27f26ed00c025b2200a9ccbb7e67ejpeg.jpeg?imageView2/1/w/114/h/114",639 "image": "http://fuss10.elemecdn.com/f/49/27f26ed00c025b2200a9ccbb7e67ejpeg.jpeg?imageView2/1/w/750/h/750"640 },641 {642 "name": "皮蛋瘦肉粥套餐",643 "price": 31,644 "oldPrice": "",645 "description": "",646 "sellCount": 12,647 "rating": 100,648 "info": "",649 "ratings": [650 {651 "username": "2******3",652 "rateTime": 1469271264000,653 "rateType": 0,654 "text": "",655 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"656 }657 ],658 "icon": "http://fuss10.elemecdn.com/8/96/f444a8087f0e940ef264617f9d98ajpeg.jpeg?imageView2/1/w/114/h/114",659 "image": "http://fuss10.elemecdn.com/8/96/f444a8087f0e940ef264617f9d98ajpeg.jpeg?imageView2/1/w/750/h/750"660 }661 ]662 },663 {664 "name": "果拼果汁",665 "type": -1,666 "foods": [667 {668 "name": "蜜瓜圣女萝莉杯",669 "price": 6,670 "oldPrice": "",671 "description": "",672 "sellCount": 1,673 "rating": "",674 "info": "",675 "ratings": [],676 "icon": "http://fuss10.elemecdn.com/b/5f/b3b04c259d5ec9fa52e1856ee50dajpeg.jpeg?imageView2/1/w/114/h/114",677 "image": "http://fuss10.elemecdn.com/b/5f/b3b04c259d5ec9fa52e1856ee50dajpeg.jpeg?imageView2/1/w/750/h/750"678 },679 {680 "name": "加多宝",681 "price": 6,682 "oldPrice": "",683 "description": "",684 "sellCount": 7,685 "rating": 100,686 "info": "",687 "ratings": [688 {689 "username": "3******c",690 "rateTime": 1469281964000,691 "rateType": 0,692 "text": "",693 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"694 },695 {696 "username": "2******3",697 "rateTime": 1469271264000,698 "rateType": 0,699 "text": "",700 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"701 },702 {703 "username": "3******b",704 "rateTime": 1469261964000,705 "rateType": 0,706 "text": "",707 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"708 }709 ],710 "icon": "http://fuss10.elemecdn.com/b/9f/5e6c99c593cf65229225c5661bcdejpeg.jpeg?imageView2/1/w/114/h/114",711 "image": "http://fuss10.elemecdn.com/b/9f/5e6c99c593cf65229225c5661bcdejpeg.jpeg?imageView2/1/w/750/h/750"712 },713 {714 "name": "VC无限橙果汁",715 "price": 8,716 "oldPrice": 10,717 "description": "",718 "sellCount": 15,719 "rating": 100,720 "info": "",721 "ratings": [722 {723 "username": "3******c",724 "rateTime": 1469281964000,725 "rateType": 0,726 "text": "还可以",727 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"728 },729 {730 "username": "2******3",731 "rateTime": 1469271264000,732 "rateType": 0,733 "text": "",734 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"735 }736 ],737 "icon": "http://fuss10.elemecdn.com/e/c6/f348e811772016ae24e968238bcbfjpeg.jpeg?imageView2/1/w/114/h/114",738 "image": "http://fuss10.elemecdn.com/e/c6/f348e811772016ae24e968238bcbfjpeg.jpeg?imageView2/1/w/750/h/750"739 }740 ]741 },742 {743 "name": "小吃主食",744 "type": -1,745 "foods": [746 {747 "name": "扁豆焖面",748 "price": 14,749 "oldPrice": "",750 "description": "",751 "sellCount": 188,752 "rating": 96,753 "info": "",754 "ratings": [755 {756 "username": "3******c",757 "rateTime": 1469281964000,758 "rateType": 0,759 "text": "",760 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"761 },762 {763 "username": "2******3",764 "rateTime": 1469271264000,765 "rateType": 0,766 "text": "",767 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"768 },769 {770 "username": "3******b",771 "rateTime": 1469261964000,772 "rateType": 1,773 "text": "",774 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"775 }776 ],777 "icon": "http://fuss10.elemecdn.com/c/6b/29e3d29b0db63d36f7c500bca31d8jpeg.jpeg?imageView2/1/w/114/h/114",778 "image": "http://fuss10.elemecdn.com/c/6b/29e3d29b0db63d36f7c500bca31d8jpeg.jpeg?imageView2/1/w/750/h/750"779 },780 {781 "name": "葱花饼",782 "price": 10,783 "oldPrice": "",784 "description": "",785 "sellCount": 124,786 "rating": 85,787 "info": "",788 "ratings": [789 {790 "username": "3******c",791 "rateTime": 1469281964000,792 "rateType": 1,793 "text": "没啥味道",794 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"795 },796 {797 "username": "2******3",798 "rateTime": 1469271264000,799 "rateType": 1,800 "text": "很一般啊",801 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"802 },803 {804 "username": "3******b",805 "rateTime": 1469261964000,806 "rateType": 0,807 "text": "",808 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"809 }810 ],811 "icon": "http://fuss10.elemecdn.com/f/28/a51e7b18751bcdf871648a23fd3b4jpeg.jpeg?imageView2/1/w/114/h/114",812 "image": "http://fuss10.elemecdn.com/f/28/a51e7b18751bcdf871648a23fd3b4jpeg.jpeg?imageView2/1/w/750/h/750"813 },814 {815 "name": "牛肉馅饼",816 "price": 14,817 "oldPrice": "",818 "description": "",819 "sellCount": 114,820 "rating": 91,821 "info": "",822 "ratings": [823 {824 "username": "3******c",825 "rateTime": 1469281964000,826 "rateType": 1,827 "text": "难吃不推荐",828 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"829 },830 {831 "username": "2******3",832 "rateTime": 1469271264000,833 "rateType": 0,834 "text": "",835 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"836 },837 {838 "username": "3******b",839 "rateTime": 1469261964000,840 "rateType": 0,841 "text": "",842 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"843 }844 ],845 "icon": "http://fuss10.elemecdn.com/d/b9/bcab0e8ad97758e65ae5a62b2664ejpeg.jpeg?imageView2/1/w/114/h/114",846 "image": "http://fuss10.elemecdn.com/d/b9/bcab0e8ad97758e65ae5a62b2664ejpeg.jpeg?imageView2/1/w/750/h/750"847 },848 {849 "name": "招牌猪肉白菜锅贴/10个",850 "price": 17,851 "oldPrice": "",852 "description": "",853 "sellCount": 101,854 "rating": 78,855 "info": "",856 "ratings": [857 {858 "username": "3******c",859 "rateTime": 1469281964000,860 "rateType": 1,861 "text": "不脆,不好吃",862 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"863 },864 {865 "username": "2******3",866 "rateTime": 1469271264000,867 "rateType": 0,868 "text": "",869 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"870 },871 {872 "username": "3******b",873 "rateTime": 1469261964000,874 "rateType": 0,875 "text": "",876 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"877 }878 ],879 "icon": "http://fuss10.elemecdn.com/7/72/9a580c1462ca1e4d3c07e112bc035jpeg.jpeg?imageView2/1/w/114/h/114",880 "image": "http://fuss10.elemecdn.com/7/72/9a580c1462ca1e4d3c07e112bc035jpeg.jpeg?imageView2/1/w/750/h/750"881 },882 {883 "name": "糊塌子",884 "price": 10,885 "oldPrice": "",886 "description": "",887 "sellCount": 80,888 "rating": 93,889 "info": "",890 "ratings": [891 {892 "username": "3******c",893 "rateTime": 1469281964000,894 "rateType": 0,895 "text": "",896 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"897 },898 {899 "username": "2******3",900 "rateTime": 1469271264000,901 "rateType": 0,902 "text": "",903 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"904 },905 {906 "username": "3******b",907 "rateTime": 1469261964000,908 "rateType": 0,909 "text": "",910 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"911 }912 ],913 "icon": "http://fuss10.elemecdn.com/0/05/097a2a59fd2a2292d08067e16380cjpeg.jpeg?imageView2/1/w/114/h/114",914 "image": "http://fuss10.elemecdn.com/0/05/097a2a59fd2a2292d08067e16380cjpeg.jpeg?imageView2/1/w/750/h/750"915 }916 ]917 },918 {919 "name": "特色粥品",920 "type": -1,921 "foods": [922 {923 "name": "皮蛋瘦肉粥",924 "price": 10,925 "oldPrice": "",926 "description": "咸粥",927 "sellCount": 229,928 "rating": 100,929 "ratings": [930 {931 "username": "3******c",932 "rateTime": 1469281964000,933 "rateType": 0,934 "text": "很喜欢的粥",935 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"936 },937 {938 "username": "2******3",939 "rateTime": 1469271264000,940 "rateType": 0,941 "text": "",942 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"943 },944 {945 "username": "3******b",946 "rateTime": 1469261964000,947 "rateType": 1,948 "text": "",949 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"950 }951 ],952 "icon": "http://fuss10.elemecdn.com/c/cd/c12745ed8a5171e13b427dbc39401jpeg.jpeg?imageView2/1/w/114/h/114",953 "image": "http://fuss10.elemecdn.com/c/cd/c12745ed8a5171e13b427dbc39401jpeg.jpeg?imageView2/1/w/750/h/750"954 },955 {956 "name": "南瓜粥",957 "price": 9,958 "oldPrice": "",959 "description": "甜粥",960 "sellCount": 91,961 "rating": 100,962 "info": "",963 "ratings": [964 {965 "username": "3******c",966 "rateTime": 1469281964000,967 "rateType": 0,968 "text": "",969 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"970 },971 {972 "username": "2******3",973 "rateTime": 1469271264000,974 "rateType": 0,975 "text": "",976 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"977 },978 {979 "username": "3******b",980 "rateTime": 1469261964000,981 "rateType": 0,982 "text": "",983 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"984 }985 ],986 "icon": "http://fuss10.elemecdn.com/8/a6/453f65f16b1391942af11511b7a90jpeg.jpeg?imageView2/1/w/114/h/114",987 "image": "http://fuss10.elemecdn.com/8/a6/453f65f16b1391942af11511b7a90jpeg.jpeg?imageView2/1/w/750/h/750"988 },989 {990 "name": "红豆薏米美肤粥",991 "price": 12,992 "oldPrice": "",993 "description": "甜粥",994 "sellCount": 86,995 "rating": 100,996 "info": "",997 "ratings": [998 {999 "username": "3******c",1000 "rateTime": 1469281964000,1001 "rateType": 0,1002 "text": "",1003 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1004 },1005 {1006 "username": "2******3",1007 "rateTime": 1469271264000,1008 "rateType": 0,1009 "text": "",1010 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1011 },1012 {1013 "username": "3******b",1014 "rateTime": 1469261964000,1015 "rateType": 0,1016 "text": "",1017 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1018 }1019 ],1020 "icon": "http://fuss10.elemecdn.com/d/22/260bd78ee6ac6051136c5447fe307jpeg.jpeg?imageView2/1/w/114/h/114",1021 "image": "http://fuss10.elemecdn.com/d/22/260bd78ee6ac6051136c5447fe307jpeg.jpeg?imageView2/1/w/750/h/750"1022 },1023 {1024 "name": "红枣山药糙米粥",1025 "price": 10,1026 "oldPrice": "",1027 "description": "",1028 "sellCount": 81,1029 "rating": 91,1030 "info": "",1031 "ratings": [1032 {1033 "username": "3******c",1034 "rateTime": 1469281964000,1035 "rateType": 0,1036 "text": "",1037 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1038 },1039 {1040 "username": "2******3",1041 "rateTime": 1469271264000,1042 "rateType": 0,1043 "text": "",1044 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1045 },1046 {1047 "username": "3******b",1048 "rateTime": 1469261964000,1049 "rateType": 0,1050 "text": "",1051 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1052 }1053 ],1054 "icon": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114",1055 "image": "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/750/h/750"1056 },1057 {1058 "name": "鲜蔬菌菇粥",1059 "price": 11,1060 "oldPrice": "",1061 "description": "咸粥",1062 "sellCount": 56,1063 "rating": 100,1064 "info": "",1065 "ratings": [1066 {1067 "username": "3******c",1068 "rateTime": 1469281964000,1069 "rateType": 0,1070 "text": "",1071 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1072 },1073 {1074 "username": "2******3",1075 "rateTime": 1469271264000,1076 "rateType": 0,1077 "text": ""1078 },1079 {1080 "username": "3******b",1081 "rateTime": 1469261964000,1082 "rateType": 0,1083 "text": "",1084 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1085 }1086 ],1087 "icon": "http://fuss10.elemecdn.com/e/a3/5317c68dd618929b6ac05804e429ajpeg.jpeg?imageView2/1/w/114/h/114",1088 "image": "http://fuss10.elemecdn.com/e/a3/5317c68dd618929b6ac05804e429ajpeg.jpeg?imageView2/1/w/750/h/750"1089 },1090 {1091 "name": "田园蔬菜粥",1092 "price": 10,1093 "oldPrice": "",1094 "description": "咸粥",1095 "sellCount": 33,1096 "rating": 100,1097 "info": "",1098 "ratings": [1099 {1100 "username": "3******c",1101 "rateTime": 1469281964000,1102 "rateType": 0,1103 "text": "",1104 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1105 },1106 {1107 "username": "2******3",1108 "rateTime": 1469271264000,1109 "rateType": 0,1110 "text": "",1111 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1112 },1113 {1114 "username": "3******b",1115 "rateTime": 1469261964000,1116 "rateType": 0,1117 "text": "",1118 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png"1119 }1120 ],1121 "icon": "http://fuss10.elemecdn.com/a/94/7371083792c19df00e546b29e344cjpeg.jpeg?imageView2/1/w/114/h/114",1122 "image": "http://fuss10.elemecdn.com/a/94/7371083792c19df00e546b29e344cjpeg.jpeg?imageView2/1/w/750/h/750"1123 }1124 ]1125 }1126 ],1127 "ratings": [1128 {1129 "username": "3******c",1130 "rateTime": 1469281964000,1131 "deliveryTime": 30,1132 "score": 5,1133 "rateType": 0,1134 "text": "不错,粥很好喝,我经常吃这一家,非常赞,以后也会常来吃,强烈推荐.",1135 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1136 "recommend": [1137 "南瓜粥",1138 "皮蛋瘦肉粥",1139 "扁豆焖面",1140 "娃娃菜炖豆腐",1141 "牛肉馅饼"1142 ]1143 },1144 {1145 "username": "2******3",1146 "rateTime": 1469271264000,1147 "deliveryTime": "",1148 "score": 4,1149 "rateType": 0,1150 "text": "服务态度不错",1151 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1152 "recommend": [1153 "扁豆焖面"1154 ]1155 },1156 {1157 "username": "3******b",1158 "rateTime": 1469261964000,1159 "score": 3,1160 "rateType": 1,1161 "text": "",1162 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1163 "recommend": []1164 },1165 {1166 "username": "1******c",1167 "rateTime": 1469261864000,1168 "deliveryTime": 20,1169 "score": 5,1170 "rateType": 0,1171 "text": "良心店铺",1172 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1173 "recommend": []1174 },1175 {1176 "username": "2******d",1177 "rateTime": 1469251264000,1178 "deliveryTime": 10,1179 "score": 4,1180 "rateType": 0,1181 "text": "",1182 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1183 "recommend": []1184 },1185 {1186 "username": "9******0",1187 "rateTime": 1469241964000,1188 "deliveryTime": 70,1189 "score": 1,1190 "rateType": 1,1191 "text": "送货速度蜗牛一样",1192 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1193 "recommend": []1194 },1195 {1196 "username": "d******c",1197 "rateTime": 1469231964000,1198 "deliveryTime": 30,1199 "score": 5,1200 "rateType": 0,1201 "text": "很喜欢的粥店",1202 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1203 "recommend": []1204 },1205 {1206 "username": "2******3",1207 "rateTime": 1469221264000,1208 "deliveryTime": "",1209 "score": 4,1210 "rateType": 0,1211 "text": "量给的还可以",1212 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1213 "recommend": []1214 },1215 {1216 "username": "3******8",1217 "rateTime": 1469211964000,1218 "deliveryTime": "",1219 "score": 3,1220 "rateType": 1,1221 "text": "",1222 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1223 "recommend": []1224 },1225 {1226 "username": "a******a",1227 "rateTime": 1469201964000,1228 "deliveryTime": "",1229 "score": 4,1230 "rateType": 0,1231 "text": "孩子喜欢吃这家",1232 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1233 "recommend": [1234 "南瓜粥"1235 ]1236 },1237 {1238 "username": "3******3",1239 "rateTime": 1469191264000,1240 "deliveryTime": "",1241 "score": 4,1242 "rateType": 0,1243 "text": "粥挺好吃的",1244 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1245 "recommend": []1246 },1247 {1248 "username": "t******b",1249 "rateTime": 1469181964000,1250 "deliveryTime": "",1251 "score": 3,1252 "rateType": 1,1253 "text": "",1254 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1255 "recommend": []1256 },1257 {1258 "username": "f******c",1259 "rateTime": 1469171964000,1260 "deliveryTime": 15,1261 "score": 5,1262 "rateType": 0,1263 "text": "送货速度很快",1264 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1265 "recommend": []1266 },1267 {1268 "username": "k******3",1269 "rateTime": 1469161264000,1270 "deliveryTime": "",1271 "score": 4,1272 "rateType": 0,1273 "text": "",1274 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1275 "recommend": []1276 },1277 {1278 "username": "u******b",1279 "rateTime": 1469151964000,1280 "deliveryTime": "",1281 "score": 4,1282 "rateType": 0,1283 "text": "下雨天给快递小哥点个赞",1284 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1285 "recommend": []1286 },1287 {1288 "username": "s******c",1289 "rateTime": 1469141964000,1290 "deliveryTime": "",1291 "score": 4,1292 "rateType": 0,1293 "text": "好",1294 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1295 "recommend": []1296 },1297 {1298 "username": "z******3",1299 "rateTime": 1469131264000,1300 "deliveryTime": "",1301 "score": 5,1302 "rateType": 0,1303 "text": "吃了还想再吃",1304 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1305 "recommend": []1306 },1307 {1308 "username": "n******b",1309 "rateTime": 1469121964000,1310 "deliveryTime": "",1311 "score": 3,1312 "rateType": 1,1313 "text": "发票开的不对",1314 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1315 "recommend": []1316 },1317 {1318 "username": "m******c",1319 "rateTime": 1469111964000,1320 "deliveryTime": 30,1321 "score": 5,1322 "rateType": 0,1323 "text": "好吃",1324 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1325 "recommend": []1326 },1327 {1328 "username": "l******3",1329 "rateTime": 1469101264000,1330 "deliveryTime": 40,1331 "score": 5,1332 "rateType": 0,1333 "text": "还不错吧",1334 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1335 "recommend": []1336 },1337 {1338 "username": "3******o",1339 "rateTime": 1469091964000,1340 "deliveryTime": "",1341 "score": 2,1342 "rateType": 1,1343 "text": "",1344 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1345 "recommend": []1346 },1347 {1348 "username": "3******p",1349 "rateTime": 1469081964000,1350 "deliveryTime": "",1351 "score": 4,1352 "rateType": 0,1353 "text": "很喜欢的粥",1354 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1355 "recommend": []1356 },1357 {1358 "username": "o******k",1359 "rateTime": 1469071264000,1360 "deliveryTime": "",1361 "score": 5,1362 "rateType": 0,1363 "text": "",1364 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1365 "recommend": []1366 },1367 {1368 "username": "k******b",1369 "rateTime": 1469061964000,1370 "deliveryTime": "",1371 "score": 4,1372 "rateType": 0,1373 "text": "",1374 "avatar": "http://static.galileo.xiaojukeji.com/static/tms/default_header.png",1375 "recommend": []1376 }1377 ] ...

Full Screen

Full Screen

nav-controller.spec.ts

Source:nav-controller.spec.ts Github

copy

Full Screen

1import { newSpecPage, mockWindow } from '@stencil/core/testing';2import { ComponentProps } from '../../../interface';3import { Nav } from '../nav';4import { NavOptions } from '../nav-interface';5import { ViewController } from '../view-controller';6import { Config } from '../../../global/config';7describe('NavController', () => {8 describe('push and pop', () => {9 it('should push multiple times and pop multiple times', async () => {10 const push1Done = jest.fn();11 const push2Done = jest.fn();12 const push3Done = jest.fn();13 const push4Done = jest.fn();14 const pop1Done = jest.fn();15 const pop2Done = jest.fn();16 const pop3Done = jest.fn();17 // Push 118 const view1 = mockView(MockView1);19 await nav.push(view1, null, { animated: false }, push1Done);20 const hasCompleted = true;21 const requiresTransition = true;22 expect(push1Done).toHaveBeenCalledWith(23 hasCompleted, requiresTransition, view1, undefined, 'forward'24 );25 expect(nav.getLength()).toEqual(1);26 expect(nav['views'][0].component).toEqual(MockView1);27 // Push 228 const view2 = mockView(MockView2);29 await nav.push(view2, null, { animated: false }, push2Done);30 expect(push2Done).toHaveBeenCalledWith(31 hasCompleted, requiresTransition, view2, view1, 'forward'32 );33 expect(nav.getLength()).toEqual(2);34 expect(nav['views'][0].component).toEqual(MockView1);35 expect(nav['views'][1].component).toEqual(MockView2);36 // Push 337 const view3 = mockView(MockView3);38 await nav.push(view3, null, { animated: false }, push3Done);39 expect(push3Done).toHaveBeenCalledWith(40 hasCompleted, requiresTransition, view3, view2, 'forward'41 );42 expect(nav.getLength()).toEqual(3);43 expect(nav['views'][0].component).toEqual(MockView1);44 expect(nav['views'][1].component).toEqual(MockView2);45 expect(nav['views'][2].component).toEqual(MockView3);46 // Push 447 const view4 = mockView(MockView4);48 await nav.push(view4, null, { animated: false }, push4Done);49 expect(push4Done).toHaveBeenCalledWith(50 hasCompleted, requiresTransition, view4, view3, 'forward'51 );52 expect(nav.getLength()).toEqual(4);53 expect(nav['views'][0].component).toEqual(MockView1);54 expect(nav['views'][1].component).toEqual(MockView2);55 expect(nav['views'][2].component).toEqual(MockView3);56 expect(nav['views'][3].component).toEqual(MockView4);57 // Pop 158 await nav.pop({ animated: false }, pop1Done);59 expect(pop1Done).toHaveBeenCalledWith(60 hasCompleted, requiresTransition, view3, view4, 'back'61 );62 expect(nav.getLength()).toEqual(3);63 expect(nav['views'][0].component).toEqual(MockView1);64 expect(nav['views'][1].component).toEqual(MockView2);65 expect(nav['views'][2].component).toEqual(MockView3);66 // Pop 267 await nav.pop({ animated: false }, pop2Done);68 expect(pop2Done).toHaveBeenCalledWith(69 hasCompleted, requiresTransition, view2, view3, 'back'70 );71 expect(nav.getLength()).toEqual(2);72 expect(nav['views'][0].component).toEqual(MockView1);73 expect(nav['views'][1].component).toEqual(MockView2);74 // Pop 375 await nav.pop({ animated: false }, pop3Done);76 expect(pop3Done).toHaveBeenCalledWith(77 hasCompleted, requiresTransition, view1, view2, 'back'78 );79 expect(nav.getLength()).toEqual(1);80 expect(nav['views'][0].component).toEqual(MockView1);81 }, 10000);82 });83 describe('push', () => {84 it('should push a component as the first view', async () => {85 const view1 = mockView(MockView1);86 await nav.push(view1, null, null, trnsDone);87 const hasCompleted = true;88 const requiresTransition = true;89 expect(trnsDone).toHaveBeenCalledWith(90 hasCompleted, requiresTransition, view1, undefined, 'forward'91 );92 expect(nav.getLength()).toEqual(1);93 expect(nav['views'][0].component).toEqual(MockView1);94 expect(nav['isTransitioning']).toEqual(false);95 }, 10000);96 it('should push a component as the second view at the end', async () => {97 const view1 = mockView(MockView1);98 mockViews(nav, [view1]);99 const view2 = mockView(MockView2);100 101 await nav.push(view2, null, null, trnsDone);102 103 const hasCompleted = true;104 const requiresTransition = true;105 expect(trnsDone).toHaveBeenCalledWith(106 hasCompleted, requiresTransition, view2, view1, 'forward'107 );108 expect(nav.getLength()).toEqual(2);109 expect(nav['views'][0].component).toEqual(MockView1);110 expect(nav['views'][1].component).toEqual(MockView2);111 expect(nav['isTransitioning']).toEqual(false);112 }, 10000);113 it('should push a ViewController as the second view and fire lifecycles', async () => {114 const view1 = mockView();115 const view2 = mockView();116 const instance1 = spyOnLifecycles(view1);117 const instance2 = spyOnLifecycles(view2);118 mockViews(nav, [view1]);119 await nav.push(view2, null, null, trnsDone);120 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();121 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();122 expect(instance1.ionViewWillLeave).toHaveBeenCalled();123 expect(instance1.ionViewDidLeave).toHaveBeenCalled();124 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();125 expect(instance2.ionViewWillEnter).toHaveBeenCalled();126 expect(instance2.ionViewDidEnter).toHaveBeenCalled();127 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();128 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();129 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();130 const hasCompleted = true;131 const requiresTransition = true;132 expect(trnsDone).toHaveBeenCalledWith(133 hasCompleted, requiresTransition, view2, view1, 'forward'134 );135 expect(nav.getLength()).toEqual(2);136 }, 10000);137 });138 describe('insert', () => {139 it('should insert at the begining with no async transition', async () => {140 const view4 = mockView(MockView4);141 const instance4 = spyOnLifecycles(view4);142 const opts: NavOptions = {};143 mockViews(nav, [mockView(MockView1), mockView(MockView2), mockView(MockView3)]);144 await nav.insert(0, view4, null, opts, trnsDone);145 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();146 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();147 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();148 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();149 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();150 const hasCompleted = true;151 const requiresTransition = false;152 expect(trnsDone).toHaveBeenCalledWith(153 hasCompleted, requiresTransition, undefined, undefined, undefined154 );155 expect(nav.getLength()).toEqual(4);156 expect(nav['views'][0].component).toEqual(MockView4);157 expect(nav['views'][nav.getLength() - 1].component).toEqual(MockView3);158 }, 10000);159 it('should insert at the end when given -1', async () => {160 const opts: NavOptions = {};161 const view1 = mockView(MockView1);162 mockViews(nav, [view1]);163 const view2 = mockView(MockView2);164 await nav.insert(-1, view2, null, opts, trnsDone);165 const hasCompleted = true;166 const requiresTransition = true;167 expect(trnsDone).toHaveBeenCalledWith(168 hasCompleted, requiresTransition, view2, view1, 'forward'169 );170 expect(nav.getLength()).toEqual(2);171 expect(nav['views'][nav.getLength() - 1].component).toEqual(MockView2);172 }, 10000);173 it('should insert at the end when given a number greater than actual length', async () => {174 const view1 = mockView(MockView1);175 mockViews(nav, [view1]);176 const view2 = mockView(MockView2);177 await nav.insert(9999, view2, null, null, trnsDone);178 const hasCompleted = true;179 const requiresTransition = true;180 expect(trnsDone).toHaveBeenCalledWith(181 hasCompleted, requiresTransition, view2, view1, 'forward'182 );183 expect(nav.getLength()).toEqual(2);184 expect(nav['views'][nav.getLength() - 1].component).toEqual(MockView2);185 }, 10000);186 it('should not insert if null view', done => {187 mockViews(nav, [mockView(MockView1)]);188 nav.insert(-1, null as any, null, null, trnsDone).then(() => {189 fail('it should not succeed');190 done();191 }).catch((err: Error) => {192 const hasCompleted = false;193 const requiresTransition = false;194 const rejectReason = new Error('invalid views to insert');195 expect(err).toEqual(rejectReason);196 expect(trnsDone).toHaveBeenCalledWith(hasCompleted, requiresTransition, rejectReason);197 expect(nav.getLength()).toEqual(1);198 expect(nav['views'][nav.getLength() - 1].component).toEqual(MockView1);199 done();200 });201 }, 10000);202 });203 describe('insertPages', () => {204 it('should insert all pages in the middle', async () => {205 const view4 = mockView(MockView4);206 const instance4 = spyOnLifecycles(view4);207 const view1 = mockView(MockView1);208 const view2 = mockView(MockView2);209 const view3 = mockView(MockView3);210 mockViews(nav, [view1, view2, view3]);211 const view5 = mockView(MockView5);212 await nav.insertPages(1, [view4, view5], null, trnsDone);213 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();214 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();215 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();216 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();217 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();218 const hasCompleted = true;219 const requiresTransition = false;220 expect(trnsDone).toHaveBeenCalledWith(221 hasCompleted, requiresTransition, undefined, undefined, undefined222 );223 expect(nav.getLength()).toEqual(5);224 expect(nav['views'][0].component).toEqual(MockView1);225 expect(nav['views'][1].component).toEqual(MockView4);226 expect(nav['views'][2].component).toEqual(MockView5);227 expect(nav['views'][3].component).toEqual(MockView2);228 expect(nav['views'][4].component).toEqual(MockView3);229 expect(nav['views'][1].nav).toEqual(nav);230 expect(nav['views'][2].nav).toEqual(nav);231 }, 10000);232 });233 describe('pop', () => {234 it('should not pop when no views in the stack', done => {235 nav.pop(null, trnsDone).then(() => {236 fail('it should not succeed');237 done();238 }).catch((err: any) => {239 const hasCompleted = false;240 const requiresTransition = false;241 const rejectReason = new Error('no views in the stack to be removed');242 expect(trnsDone).toHaveBeenCalledWith(243 hasCompleted, requiresTransition, rejectReason244 );245 expect(err).toEqual(rejectReason);246 expect(nav.getLength()).toEqual(0);247 expect(nav['isTransitioning']).toEqual(false);248 done();249 });250 }, 10000);251 it('should remove the last view and fire lifecycles', async () => {252 const view1 = mockView(MockView1);253 const view2 = mockView(MockView2);254 mockViews(nav, [view1, view2]);255 const instance1 = spyOnLifecycles(view1);256 const instance2 = spyOnLifecycles(view2);257 await nav.pop(null, trnsDone);258 expect(instance1.ionViewWillEnter).toHaveBeenCalled();259 expect(instance1.ionViewDidEnter).toHaveBeenCalled();260 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();261 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();262 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();263 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();264 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();265 expect(instance2.ionViewWillLeave).toHaveBeenCalled();266 expect(instance2.ionViewDidLeave).toHaveBeenCalled();267 expect(instance2.ionViewWillUnload).toHaveBeenCalled();268 const hasCompleted = true;269 const requiresTransition = true;270 expect(trnsDone).toHaveBeenCalledWith(271 hasCompleted, requiresTransition, view1, view2, 'back'272 );273 expect(nav.getLength()).toEqual(1);274 expect(nav['views'][0].component).toEqual(MockView1);275 expect(nav['isTransitioning']).toEqual(false);276 }, 10000);277 });278 describe('popTo', () => {279 it('should pop to a view', async () => {280 const view1 = mockView(MockView1);281 const view2 = mockView(MockView2);282 const view3 = mockView(MockView3);283 mockViews(nav, [view1, view2, view3]);284 await nav.popTo(view2, null, trnsDone);285 const hasCompleted = true;286 const requiresTransition = true;287 expect(trnsDone).toHaveBeenCalledWith(288 hasCompleted, requiresTransition, view2, view3, 'back'289 );290 expect(nav.getLength()).toEqual(2);291 expect(nav['views'][0].component).toEqual(MockView1);292 expect(nav['views'][1].component).toEqual(MockView2);293 }, 10000);294 it('should pop to using an index number', async () => {295 const view1 = mockView(MockView1);296 const view2 = mockView(MockView2);297 const view3 = mockView(MockView3);298 const view4 = mockView(MockView4);299 mockViews(nav, [view1, view2, view3, view4]);300 await nav.popTo(1, null, trnsDone);301 const hasCompleted = true;302 const requiresTransition = true;303 expect(trnsDone).toHaveBeenCalledWith(304 hasCompleted, requiresTransition, view2, view4, 'back'305 );306 expect(nav.getLength()).toEqual(2);307 expect(nav['views'][0].component).toEqual(MockView1);308 expect(nav['views'][1].component).toEqual(MockView2);309 }, 10000);310 it('should pop to first using an index number', async () => {311 const view1 = mockView(MockView1);312 const view2 = mockView(MockView2);313 const view3 = mockView(MockView3);314 const view4 = mockView(MockView4);315 mockViews(nav, [view1, view2, view3, view4]);316 const instance1 = spyOnLifecycles(view1);317 const instance2 = spyOnLifecycles(view2);318 const instance3 = spyOnLifecycles(view3);319 const instance4 = spyOnLifecycles(view4);320 await nav.popTo(0, null, trnsDone);321 expect(instance1.ionViewWillEnter).toHaveBeenCalled();322 expect(instance1.ionViewDidEnter).toHaveBeenCalled();323 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();324 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();325 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();326 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();327 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();328 expect(instance2.ionViewWillLeave).toHaveBeenCalled();329 expect(instance2.ionViewDidLeave).toHaveBeenCalled();330 expect(instance2.ionViewWillUnload).toHaveBeenCalled();331 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();332 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();333 expect(instance3.ionViewWillLeave).toHaveBeenCalled();334 expect(instance3.ionViewDidLeave).toHaveBeenCalled();335 expect(instance3.ionViewWillUnload).toHaveBeenCalled();336 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();337 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();338 expect(instance4.ionViewWillLeave).toHaveBeenCalled();339 expect(instance4.ionViewDidLeave).toHaveBeenCalled();340 expect(instance4.ionViewWillUnload).toHaveBeenCalled();341 const hasCompleted = true;342 const requiresTransition = true;343 expect(trnsDone).toHaveBeenCalledWith(344 hasCompleted, requiresTransition, view1, view4, 'back'345 );346 expect(nav.getLength()).toEqual(1);347 expect(nav['views'][0].component).toEqual(MockView1);348 }, 10000);349 });350 describe('popToRoot', () => {351 it('should pop to the first view', async () => {352 const view1 = mockView(MockView1);353 const view2 = mockView(MockView2);354 const view3 = mockView(MockView3);355 const view4 = mockView(MockView4);356 mockViews(nav, [view1, view2, view3, view4]);357 const instance1 = spyOnLifecycles(view1);358 const instance2 = spyOnLifecycles(view2);359 const instance3 = spyOnLifecycles(view3);360 const instance4 = spyOnLifecycles(view4);361 await nav.popToRoot(null, trnsDone);362 expect(instance1.ionViewWillEnter).toHaveBeenCalled();363 expect(instance1.ionViewDidEnter).toHaveBeenCalled();364 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();365 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();366 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();367 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();368 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();369 expect(instance2.ionViewWillLeave).toHaveBeenCalled();370 expect(instance2.ionViewDidLeave).toHaveBeenCalled();371 expect(instance2.ionViewWillUnload).toHaveBeenCalled();372 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();373 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();374 expect(instance3.ionViewWillLeave).toHaveBeenCalled();375 expect(instance3.ionViewDidLeave).toHaveBeenCalled();376 expect(instance3.ionViewWillUnload).toHaveBeenCalled();377 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();378 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();379 expect(instance4.ionViewWillLeave).toHaveBeenCalled();380 expect(instance4.ionViewDidLeave).toHaveBeenCalled();381 expect(instance4.ionViewWillUnload).toHaveBeenCalled();382 const hasCompleted = true;383 const requiresTransition = true;384 expect(trnsDone).toHaveBeenCalledWith(385 hasCompleted, requiresTransition, view1, view4, 'back'386 );387 expect(nav.getLength()).toEqual(1);388 expect(nav['views'][0].component).toEqual(MockView1);389 }, 10000);390 it('should not pop first view if it\'s the only view', async () => {391 const view1 = mockView(MockView1);392 mockViews(nav, [view1]);393 await nav.popToRoot(null, trnsDone);394 const hasCompleted = true;395 const requiresTransition = false;396 expect(trnsDone).toHaveBeenCalledWith(397 hasCompleted, requiresTransition, undefined, undefined, undefined398 );399 expect(nav.getLength()).toEqual(1);400 expect(nav['views'][0].component).toEqual(MockView1);401 }, 10000);402 });403 describe('remove', () => {404 it('should remove the first three views in the beginning, no last view transition', async () => {405 const view1 = mockView(MockView1);406 const view2 = mockView(MockView2);407 const view3 = mockView(MockView3);408 const view4 = mockView(MockView4);409 mockViews(nav, [view1, view2, view3, view4]);410 const instance1 = spyOnLifecycles(view1);411 const instance2 = spyOnLifecycles(view2);412 const instance3 = spyOnLifecycles(view3);413 const instance4 = spyOnLifecycles(view4);414 await nav.removeIndex(0, 3, null, trnsDone);415 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();416 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();417 expect(instance1.ionViewWillLeave).toHaveBeenCalled();418 expect(instance1.ionViewDidLeave).toHaveBeenCalled();419 expect(instance1.ionViewWillUnload).toHaveBeenCalled();420 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();421 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();422 expect(instance2.ionViewWillLeave).toHaveBeenCalled();423 expect(instance2.ionViewDidLeave).toHaveBeenCalled();424 expect(instance2.ionViewWillUnload).toHaveBeenCalled();425 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();426 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();427 expect(instance3.ionViewWillLeave).toHaveBeenCalled();428 expect(instance3.ionViewDidLeave).toHaveBeenCalled();429 expect(instance3.ionViewWillUnload).toHaveBeenCalled();430 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();431 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();432 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();433 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();434 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();435 const hasCompleted = true;436 const requiresTransition = false;437 expect(trnsDone).toHaveBeenCalledWith(438 hasCompleted, requiresTransition, undefined, undefined, undefined439 );440 expect(nav.getLength()).toEqual(1);441 expect(nav['views'][0].component).toEqual(MockView4);442 }, 10000);443 it('should remove two views in the middle', async () => {444 const view1 = mockView(MockView1);445 const view2 = mockView(MockView2);446 const view3 = mockView(MockView3);447 const view4 = mockView(MockView4);448 const view5 = mockView(MockView5);449 mockViews(nav, [view1, view2, view3, view4, view5]);450 const instance1 = spyOnLifecycles(view1);451 const instance2 = spyOnLifecycles(view2);452 const instance3 = spyOnLifecycles(view3);453 const instance4 = spyOnLifecycles(view4);454 const instance5 = spyOnLifecycles(view5);455 await nav.removeIndex(2, 2, null, trnsDone);456 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();457 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();458 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();459 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();460 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();461 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();462 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();463 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();464 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();465 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();466 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();467 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();468 expect(instance3.ionViewWillLeave).toHaveBeenCalled();469 expect(instance3.ionViewDidLeave).toHaveBeenCalled();470 expect(instance3.ionViewWillUnload).toHaveBeenCalled();471 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();472 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();473 expect(instance4.ionViewWillLeave).toHaveBeenCalled();474 expect(instance4.ionViewDidLeave).toHaveBeenCalled();475 expect(instance4.ionViewWillUnload).toHaveBeenCalled();476 expect(instance5.ionViewWillEnter).not.toHaveBeenCalled();477 expect(instance5.ionViewDidEnter).not.toHaveBeenCalled();478 expect(instance5.ionViewWillLeave).not.toHaveBeenCalled();479 expect(instance5.ionViewDidLeave).not.toHaveBeenCalled();480 expect(instance5.ionViewWillUnload).not.toHaveBeenCalled();481 const hasCompleted = true;482 const requiresTransition = false;483 expect(trnsDone).toHaveBeenCalledWith(484 hasCompleted, requiresTransition, undefined, undefined, undefined485 );486 expect(nav.getLength()).toEqual(3);487 expect(nav['views'][0].component).toEqual(MockView1);488 expect(nav['views'][1].component).toEqual(MockView2);489 expect(nav['views'][2].component).toEqual(MockView5);490 }, 10000);491 it('should remove the last two views at the end', async () => {492 const view1 = mockView(MockView1);493 const view2 = mockView(MockView2);494 const view3 = mockView(MockView3);495 const view4 = mockView(MockView4);496 mockViews(nav, [view1, view2, view3, view4]);497 const instance1 = spyOnLifecycles(view1);498 const instance2 = spyOnLifecycles(view2);499 const instance3 = spyOnLifecycles(view3);500 const instance4 = spyOnLifecycles(view4);501 await nav.removeIndex(2, 2, null, trnsDone);502 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();503 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();504 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();505 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();506 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();507 expect(instance2.ionViewWillEnter).toHaveBeenCalled();508 expect(instance2.ionViewDidEnter).toHaveBeenCalled();509 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();510 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();511 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();512 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();513 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();514 expect(instance3.ionViewWillLeave).toHaveBeenCalled();515 expect(instance3.ionViewDidLeave).toHaveBeenCalled();516 expect(instance3.ionViewWillUnload).toHaveBeenCalled();517 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();518 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();519 expect(instance4.ionViewWillLeave).toHaveBeenCalled();520 expect(instance4.ionViewDidLeave).toHaveBeenCalled();521 expect(instance4.ionViewWillUnload).toHaveBeenCalled();522 const hasCompleted = true;523 const requiresTransition = true;524 expect(trnsDone).toHaveBeenCalledWith(525 hasCompleted, requiresTransition, view2, view4, 'back'526 );527 expect(nav.getLength()).toEqual(2);528 expect(nav['views'][0].component).toEqual(MockView1);529 expect(nav['views'][1].component).toEqual(MockView2);530 }, 10000);531 });532 describe('setRoot', () => {533 it('should set a ViewController as the root when its the last view, no transition', async () => {534 const view1 = mockView(MockView1);535 const view2 = mockView(MockView2);536 const view3 = mockView(MockView3);537 mockViews(nav, [view1, view2, view3]);538 const instance1 = spyOnLifecycles(view1);539 const instance2 = spyOnLifecycles(view2);540 const instance3 = spyOnLifecycles(view3);541 await nav.setRoot(view3, null, null, trnsDone);542 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();543 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();544 expect(instance1.ionViewWillLeave).toHaveBeenCalled();545 expect(instance1.ionViewDidLeave).toHaveBeenCalled();546 expect(instance1.ionViewWillUnload).toHaveBeenCalled();547 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();548 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();549 expect(instance2.ionViewWillLeave).toHaveBeenCalled();550 expect(instance2.ionViewDidLeave).toHaveBeenCalled();551 expect(instance2.ionViewWillUnload).toHaveBeenCalled();552 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();553 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();554 expect(instance3.ionViewWillLeave).not.toHaveBeenCalled();555 expect(instance3.ionViewDidLeave).not.toHaveBeenCalled();556 expect(instance3.ionViewWillUnload).not.toHaveBeenCalled();557 const hasCompleted = true;558 const requiresTransition = false;559 expect(trnsDone).toHaveBeenCalledWith(560 hasCompleted, requiresTransition, undefined, undefined, undefined561 );562 expect(nav.getLength()).toEqual(1);563 expect(nav['views'][0].component).toEqual(MockView3);564 }, 10000);565 it('should set a ViewController as the root when its the middle view, with transition', async () => {566 const view1 = mockView(MockView1);567 const view2 = mockView(MockView2);568 const view3 = mockView(MockView3);569 mockViews(nav, [view1, view2, view3]);570 const instance1 = spyOnLifecycles(view1);571 const instance2 = spyOnLifecycles(view2);572 const instance3 = spyOnLifecycles(view3);573 await nav.setRoot(view2, null, null, trnsDone);574 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();575 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();576 expect(instance1.ionViewWillLeave).toHaveBeenCalled();577 expect(instance1.ionViewDidLeave).toHaveBeenCalled();578 expect(instance1.ionViewWillUnload).toHaveBeenCalled();579 expect(instance2.ionViewWillEnter).toHaveBeenCalled();580 expect(instance2.ionViewDidEnter).toHaveBeenCalled();581 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();582 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();583 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();584 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();585 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();586 expect(instance3.ionViewWillLeave).toHaveBeenCalled();587 expect(instance3.ionViewDidLeave).toHaveBeenCalled();588 expect(instance3.ionViewWillUnload).toHaveBeenCalled();589 const hasCompleted = true;590 const requiresTransition = true;591 expect(trnsDone).toHaveBeenCalledWith(592 hasCompleted, requiresTransition, view2, view3, 'back'593 );594 expect(nav.getLength()).toEqual(1);595 expect(nav['views'][0].component).toEqual(MockView2);596 }, 10000);597 it('should set a ViewController as the root when its the first view, with transition', async () => {598 const view1 = mockView(MockView1);599 const view2 = mockView(MockView2);600 const view3 = mockView(MockView3);601 mockViews(nav, [view1, view2, view3]);602 const instance1 = spyOnLifecycles(view1);603 const instance2 = spyOnLifecycles(view2);604 const instance3 = spyOnLifecycles(view3);605 await nav.setRoot(view1, null, null, trnsDone);606 expect(instance1.ionViewWillEnter).toHaveBeenCalled();607 expect(instance1.ionViewDidEnter).toHaveBeenCalled();608 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();609 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();610 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();611 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();612 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();613 expect(instance2.ionViewWillLeave).toHaveBeenCalled();614 expect(instance2.ionViewDidLeave).toHaveBeenCalled();615 expect(instance2.ionViewWillUnload).toHaveBeenCalled();616 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();617 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();618 expect(instance3.ionViewWillLeave).toHaveBeenCalled();619 expect(instance3.ionViewDidLeave).toHaveBeenCalled();620 expect(instance3.ionViewWillUnload).toHaveBeenCalled();621 const hasCompleted = true;622 const requiresTransition = true;623 expect(trnsDone).toHaveBeenCalledWith(624 hasCompleted, requiresTransition, view1, view3, 'back'625 );626 expect(nav.getLength()).toEqual(1);627 expect(nav['views'][0].component).toEqual(MockView1);628 }, 10000);629 it('should set a page component as the root, with transition', async () => {630 const view1 = mockView(MockView1);631 const view2 = mockView(MockView2);632 const view3 = mockView(MockView3);633 mockViews(nav, [view1, view2, view3]);634 const instance1 = spyOnLifecycles(view1);635 const instance2 = spyOnLifecycles(view2);636 const instance3 = spyOnLifecycles(view3);637 const view4 = mockView(MockView4);638 await nav.setRoot(view4, null, null, trnsDone);639 expect(instance1.ionViewWillUnload).toHaveBeenCalled();640 expect(instance2.ionViewWillUnload).toHaveBeenCalled();641 expect(instance3.ionViewWillUnload).toHaveBeenCalled();642 const hasCompleted = true;643 const requiresTransition = true;644 expect(trnsDone).toHaveBeenCalledWith(645 hasCompleted, requiresTransition, view4, view3, 'back'646 );647 expect(nav.getLength()).toEqual(1);648 expect(nav['views'][0].component).toEqual(MockView4);649 }, 10000);650 });651 describe('setPages', () => {652 it('should set the pages from an array, starting at the root, with transition', async () => {653 const view1 = mockView(MockView1);654 const view2 = mockView(MockView2);655 mockViews(nav, [view1, view2]);656 const instance1 = spyOnLifecycles(view1);657 const instance2 = spyOnLifecycles(view2);658 const view4 = mockView(MockView4);659 const view5 = mockView(MockView5);660 await nav.setPages([661 { page: view4 },662 { page: view5 }663 ], null, trnsDone);664 expect(instance1.ionViewWillUnload).toHaveBeenCalled();665 expect(instance2.ionViewWillUnload).toHaveBeenCalled();666 const hasCompleted = true;667 const requiresTransition = true;668 expect(trnsDone).toHaveBeenCalledWith(669 hasCompleted, requiresTransition, view5, view2, 'back'670 );671 expect(nav.getLength()).toEqual(2);672 expect(nav['views'][0].component).toEqual(MockView4);673 expect(nav['views'][1].component).toEqual(MockView5);674 }, 10000);675 });676 describe('canStart', () => {677 it('should not swipe back when its not enabled', () => {678 nav.swipeGesture = false;679 const view1 = mockView();680 const view2 = mockView();681 mockViews(nav, [view1, view2]);682 const result = nav['canStart']();683 expect(result).toEqual(false);684 });685 it('should swipe back when has a view to go back to', () => {686 nav.swipeGesture = true;687 const view1 = mockView();688 const view2 = mockView();689 mockViews(nav, [view1, view2]);690 const result = nav['canStart']();691 expect(result).toEqual(true);692 });693 });694 function spyOnLifecycles(view: ViewController) {695 const element = view.element as any;696 Object.assign(element, {697 ionViewWillEnter: () => {698 return;699 },700 ionViewDidEnter: () => {701 return;702 },703 ionViewWillLeave: () => {704 return;705 },706 ionViewDidLeave: () => {707 return;708 },709 ionViewWillUnload: () => {710 return;711 },712 });713 const instance = {714 ionViewWillEnter: jest.spyOn(element, 'ionViewWillEnter'),715 ionViewDidEnter: jest.spyOn(element, 'ionViewDidEnter'),716 ionViewWillLeave: jest.spyOn(element, 'ionViewWillLeave'),717 ionViewDidLeave: jest.spyOn(element, 'ionViewDidLeave'),718 ionViewWillUnload: jest.spyOn(element, 'ionViewWillUnload'),719 };720 element.dispatchEvent = (ev: CustomEvent) => {721 switch(ev.type) {722 case 'ionViewWillEnter': element.ionViewWillEnter(); break;723 case 'ionViewDidEnter': element.ionViewDidEnter(); break;724 case 'ionViewWillLeave': element.ionViewWillLeave(); break;725 case 'ionViewDidLeave': element.ionViewDidLeave(); break;726 case 'ionViewWillUnload': element.ionViewWillUnload(); break;727 }728 };729 return instance;730 }731 let trnsDone: jest.Mock;732 let nav: Nav;733 beforeEach(async () => {734 trnsDone = jest.fn();735 const config = new Config();736 config.reset({ animated: false });737 const page = await newSpecPage({738 components: [Nav],739 html: `<ion-nav></ion-nav>`,740 autoApplyChanges: true,741 context: {742 config743 }744 });745 nav = page.rootInstance;746 });747 const MockView = 'mock-view';748 const MockView1 = 'mock-view1';749 const MockView2 = 'mock-view2';750 const MockView3 = 'mock-view3';751 const MockView4 = 'mock-view4';752 const MockView5 = 'mock-view5';753 754 const mockWebAnimation = (el: HTMLElement) => {755 Element.prototype.animate = () => {};756 757 el.animate = () => {758 const animation = {759 stop: () => {},760 pause: () => {},761 cancel: () => {},762 onfinish: undefined763 }764 765 animation.play = () => {766 if (animation.onfinish) {767 animation.onfinish();768 }769 }770 771 return animation;772 }773 }774 function mockView(component?: any, params?: ComponentProps) {775 if (!component) {776 component = MockView;777 }778 const view = new ViewController(component, params);779 view.element = document.createElement(component) as HTMLElement;780 781 mockWebAnimation(view.element);782 783 return view;784 }785 function mockViews(navI: Nav, views: ViewController[]) {786 navI['views'] = views;787 views.forEach(v => {788 v.nav = navI;789 });790 }791 // function mockNavController(): Promise<Nav> {792 // const navI = new Nav() as any;793 // navI.animated = false;794 // navI.el = win.document.createElement('ion-nav');795 // navI.win = win;796 // navI.queue = { write: (fn: any) => fn(), read: (fn: any) => fn() };797 // navI.config = new Config();798 // navI.config.reset({ animated: false });799 // navI._viewInit = (enteringView: ViewController) => {800 // if (!enteringView.element) {801 // enteringView.element = (typeof enteringView.component === 'string')802 // ? win.document.createElement(enteringView.component)803 // : enteringView.element = enteringView.component as HTMLElement;804 // }805 // enteringView.state = VIEW_STATE_ATTACHED;806 // };807 // return navI;808 // }...

Full Screen

Full Screen

splitview.test.ts

Source:splitview.test.ts Github

copy

Full Screen

1/*---------------------------------------------------------------------------------------------2 * Copyright (c) Microsoft Corporation. All rights reserved.3 * Licensed under the MIT License. See License.txt in the project root for license information.4 *--------------------------------------------------------------------------------------------*/5import * as assert from 'assert';6import { Sash, SashState } from 'vs/base/browser/ui/sash/sash';7import { IView, LayoutPriority, Sizing, SplitView } from 'vs/base/browser/ui/splitview/splitview';8import { Emitter } from 'vs/base/common/event';9class TestView implements IView<number> {10 private readonly _onDidChange = new Emitter<number | undefined>();11 readonly onDidChange = this._onDidChange.event;12 get minimumSize(): number { return this._minimumSize; }13 set minimumSize(size: number) { this._minimumSize = size; this._onDidChange.fire(undefined); }14 get maximumSize(): number { return this._maximumSize; }15 set maximumSize(size: number) { this._maximumSize = size; this._onDidChange.fire(undefined); }16 private _element: HTMLElement = document.createElement('div');17 get element(): HTMLElement { this._onDidGetElement.fire(); return this._element; }18 private readonly _onDidGetElement = new Emitter<void>();19 readonly onDidGetElement = this._onDidGetElement.event;20 private _size = 0;21 get size(): number { return this._size; }22 private _orthogonalSize: number | undefined = 0;23 get orthogonalSize(): number | undefined { return this._orthogonalSize; }24 private readonly _onDidLayout = new Emitter<{ size: number; orthogonalSize: number | undefined }>();25 readonly onDidLayout = this._onDidLayout.event;26 private readonly _onDidFocus = new Emitter<void>();27 readonly onDidFocus = this._onDidFocus.event;28 constructor(29 private _minimumSize: number,30 private _maximumSize: number,31 readonly priority: LayoutPriority = LayoutPriority.Normal32 ) {33 assert(_minimumSize <= _maximumSize, 'splitview view minimum size must be <= maximum size');34 }35 layout(size: number, _offset: number, orthogonalSize: number | undefined): void {36 this._size = size;37 this._orthogonalSize = orthogonalSize;38 this._onDidLayout.fire({ size, orthogonalSize });39 }40 focus(): void {41 this._onDidFocus.fire();42 }43 dispose(): void {44 this._onDidChange.dispose();45 this._onDidGetElement.dispose();46 this._onDidLayout.dispose();47 this._onDidFocus.dispose();48 }49}50function getSashes(splitview: SplitView): Sash[] {51 return (splitview as any).sashItems.map((i: any) => i.sash) as Sash[];52}53suite('Splitview', () => {54 let container: HTMLElement;55 setup(() => {56 container = document.createElement('div');57 container.style.position = 'absolute';58 container.style.width = `${200}px`;59 container.style.height = `${200}px`;60 });61 test('empty splitview has empty DOM', () => {62 const splitview = new SplitView(container);63 assert.strictEqual(container.firstElementChild!.firstElementChild!.childElementCount, 0, 'split view should be empty');64 splitview.dispose();65 });66 test('has views and sashes as children', () => {67 const view1 = new TestView(20, 20);68 const view2 = new TestView(20, 20);69 const view3 = new TestView(20, 20);70 const splitview = new SplitView(container);71 splitview.addView(view1, 20);72 splitview.addView(view2, 20);73 splitview.addView(view3, 20);74 let viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');75 assert.strictEqual(viewQuery.length, 3, 'split view should have 3 views');76 let sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');77 assert.strictEqual(sashQuery.length, 2, 'split view should have 2 sashes');78 splitview.removeView(2);79 viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');80 assert.strictEqual(viewQuery.length, 2, 'split view should have 2 views');81 sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');82 assert.strictEqual(sashQuery.length, 1, 'split view should have 1 sash');83 splitview.removeView(0);84 viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');85 assert.strictEqual(viewQuery.length, 1, 'split view should have 1 view');86 sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');87 assert.strictEqual(sashQuery.length, 0, 'split view should have no sashes');88 splitview.removeView(0);89 viewQuery = container.querySelectorAll('.monaco-split-view2 > .monaco-scrollable-element > .split-view-container > .split-view-view');90 assert.strictEqual(viewQuery.length, 0, 'split view should have no views');91 sashQuery = container.querySelectorAll('.monaco-split-view2 > .sash-container > .monaco-sash');92 assert.strictEqual(sashQuery.length, 0, 'split view should have no sashes');93 splitview.dispose();94 view1.dispose();95 view2.dispose();96 view3.dispose();97 });98 test('calls view methods on addView and removeView', () => {99 const view = new TestView(20, 20);100 const splitview = new SplitView(container);101 let didLayout = false;102 const layoutDisposable = view.onDidLayout(() => didLayout = true);103 const renderDisposable = view.onDidGetElement(() => undefined);104 splitview.addView(view, 20);105 assert.strictEqual(view.size, 20, 'view has right size');106 assert(didLayout, 'layout is called');107 assert(didLayout, 'render is called');108 splitview.dispose();109 layoutDisposable.dispose();110 renderDisposable.dispose();111 view.dispose();112 });113 test('stretches view to viewport', () => {114 const view = new TestView(20, Number.POSITIVE_INFINITY);115 const splitview = new SplitView(container);116 splitview.layout(200);117 splitview.addView(view, 20);118 assert.strictEqual(view.size, 200, 'view is stretched');119 splitview.layout(200);120 assert.strictEqual(view.size, 200, 'view stayed the same');121 splitview.layout(100);122 assert.strictEqual(view.size, 100, 'view is collapsed');123 splitview.layout(20);124 assert.strictEqual(view.size, 20, 'view is collapsed');125 splitview.layout(10);126 assert.strictEqual(view.size, 20, 'view is clamped');127 splitview.layout(200);128 assert.strictEqual(view.size, 200, 'view is stretched');129 splitview.dispose();130 view.dispose();131 });132 test('can resize views', () => {133 const view1 = new TestView(20, Number.POSITIVE_INFINITY);134 const view2 = new TestView(20, Number.POSITIVE_INFINITY);135 const view3 = new TestView(20, Number.POSITIVE_INFINITY);136 const splitview = new SplitView(container);137 splitview.layout(200);138 splitview.addView(view1, 20);139 splitview.addView(view2, 20);140 splitview.addView(view3, 20);141 assert.strictEqual(view1.size, 160, 'view1 is stretched');142 assert.strictEqual(view2.size, 20, 'view2 size is 20');143 assert.strictEqual(view3.size, 20, 'view3 size is 20');144 splitview.resizeView(1, 40);145 assert.strictEqual(view1.size, 140, 'view1 is collapsed');146 assert.strictEqual(view2.size, 40, 'view2 is stretched');147 assert.strictEqual(view3.size, 20, 'view3 stays the same');148 splitview.resizeView(0, 70);149 assert.strictEqual(view1.size, 70, 'view1 is collapsed');150 assert.strictEqual(view2.size, 40, 'view2 stays the same');151 assert.strictEqual(view3.size, 90, 'view3 is stretched');152 splitview.resizeView(2, 40);153 assert.strictEqual(view1.size, 70, 'view1 stays the same');154 assert.strictEqual(view2.size, 90, 'view2 is collapsed');155 assert.strictEqual(view3.size, 40, 'view3 is stretched');156 splitview.dispose();157 view3.dispose();158 view2.dispose();159 view1.dispose();160 });161 test('reacts to view changes', () => {162 const view1 = new TestView(20, Number.POSITIVE_INFINITY);163 const view2 = new TestView(20, Number.POSITIVE_INFINITY);164 const view3 = new TestView(20, Number.POSITIVE_INFINITY);165 const splitview = new SplitView(container);166 splitview.layout(200);167 splitview.addView(view1, 20);168 splitview.addView(view2, 20);169 splitview.addView(view3, 20);170 assert.strictEqual(view1.size, 160, 'view1 is stretched');171 assert.strictEqual(view2.size, 20, 'view2 size is 20');172 assert.strictEqual(view3.size, 20, 'view3 size is 20');173 view1.maximumSize = 20;174 assert.strictEqual(view1.size, 20, 'view1 is collapsed');175 assert.strictEqual(view2.size, 20, 'view2 stays the same');176 assert.strictEqual(view3.size, 160, 'view3 is stretched');177 view3.maximumSize = 40;178 assert.strictEqual(view1.size, 20, 'view1 stays the same');179 assert.strictEqual(view2.size, 140, 'view2 is stretched');180 assert.strictEqual(view3.size, 40, 'view3 is collapsed');181 view2.maximumSize = 200;182 assert.strictEqual(view1.size, 20, 'view1 stays the same');183 assert.strictEqual(view2.size, 140, 'view2 stays the same');184 assert.strictEqual(view3.size, 40, 'view3 stays the same');185 view3.maximumSize = Number.POSITIVE_INFINITY;186 view3.minimumSize = 100;187 assert.strictEqual(view1.size, 20, 'view1 is collapsed');188 assert.strictEqual(view2.size, 80, 'view2 is collapsed');189 assert.strictEqual(view3.size, 100, 'view3 is stretched');190 splitview.dispose();191 view3.dispose();192 view2.dispose();193 view1.dispose();194 });195 test('sashes are properly enabled/disabled', () => {196 const view1 = new TestView(20, Number.POSITIVE_INFINITY);197 const view2 = new TestView(20, Number.POSITIVE_INFINITY);198 const view3 = new TestView(20, Number.POSITIVE_INFINITY);199 const splitview = new SplitView(container);200 splitview.layout(200);201 splitview.addView(view1, Sizing.Distribute);202 splitview.addView(view2, Sizing.Distribute);203 splitview.addView(view3, Sizing.Distribute);204 let sashes = getSashes(splitview);205 assert.strictEqual(sashes.length, 2, 'there are two sashes');206 assert.strictEqual(sashes[0].state, SashState.Enabled, 'first sash is enabled');207 assert.strictEqual(sashes[1].state, SashState.Enabled, 'second sash is enabled');208 splitview.layout(60);209 assert.strictEqual(sashes[0].state, SashState.Disabled, 'first sash is disabled');210 assert.strictEqual(sashes[1].state, SashState.Disabled, 'second sash is disabled');211 splitview.layout(20);212 assert.strictEqual(sashes[0].state, SashState.Disabled, 'first sash is disabled');213 assert.strictEqual(sashes[1].state, SashState.Disabled, 'second sash is disabled');214 splitview.layout(200);215 assert.strictEqual(sashes[0].state, SashState.Enabled, 'first sash is enabled');216 assert.strictEqual(sashes[1].state, SashState.Enabled, 'second sash is enabled');217 view1.maximumSize = 20;218 assert.strictEqual(sashes[0].state, SashState.Disabled, 'first sash is disabled');219 assert.strictEqual(sashes[1].state, SashState.Enabled, 'second sash is enabled');220 view2.maximumSize = 20;221 assert.strictEqual(sashes[0].state, SashState.Disabled, 'first sash is disabled');222 assert.strictEqual(sashes[1].state, SashState.Disabled, 'second sash is disabled');223 view1.maximumSize = 300;224 assert.strictEqual(sashes[0].state, SashState.AtMinimum, 'first sash is enabled');225 assert.strictEqual(sashes[1].state, SashState.AtMinimum, 'second sash is enabled');226 view2.maximumSize = 200;227 assert.strictEqual(sashes[0].state, SashState.AtMinimum, 'first sash is enabled');228 assert.strictEqual(sashes[1].state, SashState.AtMinimum, 'second sash is enabled');229 splitview.resizeView(0, 40);230 assert.strictEqual(sashes[0].state, SashState.Enabled, 'first sash is enabled');231 assert.strictEqual(sashes[1].state, SashState.Enabled, 'second sash is enabled');232 splitview.dispose();233 view3.dispose();234 view2.dispose();235 view1.dispose();236 });237 test('issue #35497', () => {238 const view1 = new TestView(160, Number.POSITIVE_INFINITY);239 const view2 = new TestView(66, 66);240 const splitview = new SplitView(container);241 splitview.layout(986);242 splitview.addView(view1, 142, 0);243 assert.strictEqual(view1.size, 986, 'first view is stretched');244 view2.onDidGetElement(() => {245 assert.throws(() => splitview.resizeView(1, 922));246 assert.throws(() => splitview.resizeView(1, 922));247 });248 splitview.addView(view2, 66, 0);249 assert.strictEqual(view2.size, 66, 'second view is fixed');250 assert.strictEqual(view1.size, 986 - 66, 'first view is collapsed');251 const viewContainers = container.querySelectorAll('.split-view-view');252 assert.strictEqual(viewContainers.length, 2, 'there are two view containers');253 assert.strictEqual((viewContainers.item(0) as HTMLElement).style.height, '66px', 'second view container is 66px');254 assert.strictEqual((viewContainers.item(1) as HTMLElement).style.height, `${986 - 66}px`, 'first view container is 66px');255 splitview.dispose();256 view2.dispose();257 view1.dispose();258 });259 test('automatic size distribution', () => {260 const view1 = new TestView(20, Number.POSITIVE_INFINITY);261 const view2 = new TestView(20, Number.POSITIVE_INFINITY);262 const view3 = new TestView(20, Number.POSITIVE_INFINITY);263 const splitview = new SplitView(container);264 splitview.layout(200);265 splitview.addView(view1, Sizing.Distribute);266 assert.strictEqual(view1.size, 200);267 splitview.addView(view2, 50);268 assert.deepStrictEqual([view1.size, view2.size], [150, 50]);269 splitview.addView(view3, Sizing.Distribute);270 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 66, 68]);271 splitview.removeView(1, Sizing.Distribute);272 assert.deepStrictEqual([view1.size, view3.size], [100, 100]);273 splitview.dispose();274 view3.dispose();275 view2.dispose();276 view1.dispose();277 });278 test('add views before layout', () => {279 const view1 = new TestView(20, Number.POSITIVE_INFINITY);280 const view2 = new TestView(20, Number.POSITIVE_INFINITY);281 const view3 = new TestView(20, Number.POSITIVE_INFINITY);282 const splitview = new SplitView(container);283 splitview.addView(view1, 100);284 splitview.addView(view2, 75);285 splitview.addView(view3, 25);286 splitview.layout(200);287 assert.deepStrictEqual([view1.size, view2.size, view3.size], [67, 67, 66]);288 splitview.dispose();289 view3.dispose();290 view2.dispose();291 view1.dispose();292 });293 test('split sizing', () => {294 const view1 = new TestView(20, Number.POSITIVE_INFINITY);295 const view2 = new TestView(20, Number.POSITIVE_INFINITY);296 const view3 = new TestView(20, Number.POSITIVE_INFINITY);297 const splitview = new SplitView(container);298 splitview.layout(200);299 splitview.addView(view1, Sizing.Distribute);300 assert.strictEqual(view1.size, 200);301 splitview.addView(view2, Sizing.Split(0));302 assert.deepStrictEqual([view1.size, view2.size], [100, 100]);303 splitview.addView(view3, Sizing.Split(1));304 assert.deepStrictEqual([view1.size, view2.size, view3.size], [100, 50, 50]);305 splitview.dispose();306 view3.dispose();307 view2.dispose();308 view1.dispose();309 });310 test('split sizing 2', () => {311 const view1 = new TestView(20, Number.POSITIVE_INFINITY);312 const view2 = new TestView(20, Number.POSITIVE_INFINITY);313 const view3 = new TestView(20, Number.POSITIVE_INFINITY);314 const splitview = new SplitView(container);315 splitview.layout(200);316 splitview.addView(view1, Sizing.Distribute);317 assert.strictEqual(view1.size, 200);318 splitview.addView(view2, Sizing.Split(0));319 assert.deepStrictEqual([view1.size, view2.size], [100, 100]);320 splitview.addView(view3, Sizing.Split(0));321 assert.deepStrictEqual([view1.size, view2.size, view3.size], [50, 100, 50]);322 splitview.dispose();323 view3.dispose();324 view2.dispose();325 view1.dispose();326 });327 test('proportional layout', () => {328 const view1 = new TestView(20, Number.POSITIVE_INFINITY);329 const view2 = new TestView(20, Number.POSITIVE_INFINITY);330 const splitview = new SplitView(container);331 splitview.layout(200);332 splitview.addView(view1, Sizing.Distribute);333 splitview.addView(view2, Sizing.Distribute);334 assert.deepStrictEqual([view1.size, view2.size], [100, 100]);335 splitview.layout(100);336 assert.deepStrictEqual([view1.size, view2.size], [50, 50]);337 splitview.dispose();338 view2.dispose();339 view1.dispose();340 });341 test('disable proportional layout', () => {342 const view1 = new TestView(20, Number.POSITIVE_INFINITY);343 const view2 = new TestView(20, Number.POSITIVE_INFINITY);344 const splitview = new SplitView(container, { proportionalLayout: false });345 splitview.layout(200);346 splitview.addView(view1, Sizing.Distribute);347 splitview.addView(view2, Sizing.Distribute);348 assert.deepStrictEqual([view1.size, view2.size], [100, 100]);349 splitview.layout(100);350 assert.deepStrictEqual([view1.size, view2.size], [80, 20]);351 splitview.dispose();352 view2.dispose();353 view1.dispose();354 });355 test('high layout priority', () => {356 const view1 = new TestView(20, Number.POSITIVE_INFINITY);357 const view2 = new TestView(20, Number.POSITIVE_INFINITY, LayoutPriority.High);358 const view3 = new TestView(20, Number.POSITIVE_INFINITY);359 const splitview = new SplitView(container, { proportionalLayout: false });360 splitview.layout(200);361 splitview.addView(view1, Sizing.Distribute);362 splitview.addView(view2, Sizing.Distribute);363 splitview.addView(view3, Sizing.Distribute);364 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 68, 66]);365 splitview.layout(180);366 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 48, 66]);367 splitview.layout(124);368 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 20, 38]);369 splitview.layout(60);370 assert.deepStrictEqual([view1.size, view2.size, view3.size], [20, 20, 20]);371 splitview.layout(200);372 assert.deepStrictEqual([view1.size, view2.size, view3.size], [20, 160, 20]);373 splitview.dispose();374 view3.dispose();375 view2.dispose();376 view1.dispose();377 });378 test('low layout priority', () => {379 const view1 = new TestView(20, Number.POSITIVE_INFINITY);380 const view2 = new TestView(20, Number.POSITIVE_INFINITY);381 const view3 = new TestView(20, Number.POSITIVE_INFINITY, LayoutPriority.Low);382 const splitview = new SplitView(container, { proportionalLayout: false });383 splitview.layout(200);384 splitview.addView(view1, Sizing.Distribute);385 splitview.addView(view2, Sizing.Distribute);386 splitview.addView(view3, Sizing.Distribute);387 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 68, 66]);388 splitview.layout(180);389 assert.deepStrictEqual([view1.size, view2.size, view3.size], [66, 48, 66]);390 splitview.layout(132);391 assert.deepStrictEqual([view1.size, view2.size, view3.size], [46, 20, 66]);392 splitview.layout(60);393 assert.deepStrictEqual([view1.size, view2.size, view3.size], [20, 20, 20]);394 splitview.layout(200);395 assert.deepStrictEqual([view1.size, view2.size, view3.size], [20, 160, 20]);396 splitview.dispose();397 view3.dispose();398 view2.dispose();399 view1.dispose();400 });401 test('context propagates to views', () => {402 const view1 = new TestView(20, Number.POSITIVE_INFINITY);403 const view2 = new TestView(20, Number.POSITIVE_INFINITY);404 const view3 = new TestView(20, Number.POSITIVE_INFINITY, LayoutPriority.Low);405 const splitview = new SplitView<number>(container, { proportionalLayout: false });406 splitview.layout(200);407 splitview.addView(view1, Sizing.Distribute);408 splitview.addView(view2, Sizing.Distribute);409 splitview.addView(view3, Sizing.Distribute);410 splitview.layout(200, 100);411 assert.deepStrictEqual([view1.orthogonalSize, view2.orthogonalSize, view3.orthogonalSize], [100, 100, 100]);412 splitview.dispose();413 view3.dispose();414 view2.dispose();415 view1.dispose();416 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt2.view2();2wpt2.view1();3wpt2.view3();4wpt1.view1();5wpt1.view2();6wpt1.view3();7wpt3.view3();8wpt3.view1();9wpt3.view2();10wpt3.view3();11wpt3.view2();12wpt3.view1();13wpt2.view2();14wpt2.view3();15wpt2.view1();16wpt2.view2();17wpt2.view1();18wpt2.view3();19wpt1.view1();20wpt1.view3();21wpt1.view2();22wpt1.view1();23wpt1.view2();24wpt1.view3();25wpt3.view3();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.view2('test.com', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10wpt.view('test.com', function(err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var view2 = wpt.view2;3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var view = wpt.view;11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt');18var test = wpt.test;19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var test = wpt.test;27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('wpt');34var test = wpt.test;35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('wpt');42var test = wpt.test;43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});49var wpt = require('wpt');50var test = wpt.test;51 if (err) {52 console.log(err);53 } else {54 console.log(data);55 }56});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 }4 else {5 }6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt.view2();3exports.view2 = function() {4 console.log("view2");5};6exports.view = function() {7 console.log("view");8};

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful