How to use cache.resolve method in Cypress

Best JavaScript code snippet using cypress

app.js

Source:app.js Github

copy

Full Screen

1var app = angular.module('EasyBuy', [2    "ngRoute",3    "ngTouch",4    "mobile-angular-ui"5]);6var onlyWechatOauth=[];7var isNotBindPhone=[];8onlyWechatOauth["views/wechat/myOrder.html"]="myOrder";9onlyWechatOauth["views/wechat/myFreeOrder.html"]="myFreeOrder";10onlyWechatOauth["views/wechat/myInfo.html"]="myInfo";11onlyWechatOauth["views/wechat/car.html"]="car";12onlyWechatOauth["views/wechat/buyFree.html"]="buyFree";13onlyWechatOauth["views/wechat/easyHandsInfo.html"]="easyHandsInfo";14onlyWechatOauth["views/wechat/easyHandsInfoSuccess.html"]="easyHandsInfoSuccess";15onlyWechatOauth["views/wechat/easyHandsAgent.html"]="easyHandsAgent";16onlyWechatOauth["views/wechat/easyHandsDown.html"]="easyHandsDown";17onlyWechatOauth["views/wechat/activity.html"]="activity";18onlyWechatOauth["views/wechat/refinedProducts.html"]="refinedProducts";19onlyWechatOauth["views/user/my.html"]="myProfile";20onlyWechatOauth["views/order/airportServiceOrder.html"]="airportServiceOrder";21onlyWechatOauth["views/activity/activity201501.html"]="activity-activityDetail";22onlyWechatOauth["views/activity/down.html"]="activity-activityDown";23onlyWechatOauth["views/user/myCoupon.html"]="myCoupon";24onlyWechatOauth["views/user/myPhone.html"]="myPhone";25onlyWechatOauth["views/wechat/myAirportInfo.html"]="wechat-myAirportInfo";26onlyWechatOauth["views/wechat/myWiFi.html"]="wechat-myWiFi";27//onlyWechatOauth["views/activity/activity201501.html"]="activity-activityDetail";28isNotBindPhone["activity-activityDetail"]=true;29isNotBindPhone["activity-activityDown"]=true;30//isNotBindPhone["myCoupon"]=true;31isNotBindPhone["myPhone"]=true;32var baseOauth=[];33baseOauth["activity-activityDetail"]=true;34baseOauth["activity-activityDown"]=true;35baseOauth["myPhone"]=true;36baseOauth["myCoupon"]=true;37baseOauth["orderList"]=true;38baseOauth["wechat-myAirportInfo"]=true;39baseOauth["wechat-myWiFi"]=true;40var isContainFind=[];41isContainFind["activity-activityDown"]=true;42var preventCache=Math.random().toString(36);43app.config(function ($routeProvider, $locationProvider,$controllerProvider,$compileProvider,$filterProvider,$provide) {44	app.register = {45		controller: $controllerProvider.register,46		directive: $compileProvider.directive,47		filter: $filterProvider.register,48		factory: $provide.factory,49		service: $provide.service50	};51	app.asyncjs = function (js) {52		return ["$q", "$route", "$rootScope", function ($q, $route, $rootScope) {53			var deferred = $q.defer();54			var dependencies = js;55			if (Array.isArray(dependencies)) {56				for (var i = 0; i < dependencies.length; i++) {57					dependencies[i] += "?v=" + preventCache;58				}59			} else {60				dependencies += "?v=" + preventCache;//v是版本号61			}62			$script(dependencies, function () {63				$rootScope.$apply(function () {64					deferred.resolve();65				});66			});67			return deferred.promise;68		}];69	}70    $routeProvider71        .when('/products', { templateUrl: "views/goods/productList.html?"+preventCache,controller:'productsController'})72        .when('/products/:code', { templateUrl: "views/goods/products.html?"+preventCache })73        .when('/pay/:id', { templateUrl: "views/pay/payment.html?"+preventCache })74        .when('/pay/:id/:from', { templateUrl: "views/pay/payment.html?"+preventCache })75        .when('/dividedPay/:orderNum/:fee', { templateUrl: "views/pay/dividedPay.html?"+preventCache })76        .when('/dividedPay/success', { templateUrl: "views/pay/success2.html?"+preventCache })77        .when('/address/:payid', { templateUrl: "views/order/address.html?"+preventCache78			,resolve: {79				load: app.asyncjs(['lib/mobiscroll.zepto.js','lib/mobiscroll.custom-2.6.2.js'])80			}81        })82        .when('/address/:payid/:buyType', { templateUrl: "views/order/address2.html?"+preventCache83			,resolve: {84				load: app.asyncjs(['lib/mobiscroll.zepto.js','lib/mobiscroll.custom-2.6.2.js'])85			}86        })87        .when('/success/:ordersn/:mobile/:address/:time', { templateUrl: "views/pay/success.html?"+preventCache })88        .when('/success/:ordersn/:token', { templateUrl: "views/pay/success.html?"+preventCache })89        .when('/success/:ordersn', { templateUrl: "views/pay/success.html?"+preventCache })90        .when('/success', { templateUrl: "views/pay/success.html?"+preventCache })91        .when('/error', { templateUrl: "views/pay/error.html?"+preventCache })92        .when('/error/:orderId/:mobile', { templateUrl: "views/pay/error.html?"+preventCache })93        .when('/orderDetail', { templateUrl: "views/order/orderDetail.html?"+preventCache })94        .when('/orderDetail/:id', { templateUrl: "views/order/orderDetail.html?"+preventCache })95        .when('/orderDetail/:id/:token', { templateUrl: "views/order/orderDetail.html?"+preventCache })96        .when('/orderList', { templateUrl: "views/order/orderList.html?"+preventCache })97        .when('/orderList/:token', { templateUrl: "views/order/orderList.html?"+preventCache })98        99        .when('/orderInquiry', { templateUrl: "views/order/orderInquiry.html?"+preventCache })100        .when('/product/:id', { templateUrl: "views/goods/productApp.html?"+preventCache,controller:'productAppController'})101        .when('/product/:id/:from', { templateUrl: "views/goods/productApp.html?"+preventCache,controller:'productAppController'})102        .when('/product/:id/:from/:type', { templateUrl: "views/goods/productApp.html?"+preventCache,controller:'productAppController'})103        104        .when('/productDetail/:id', { templateUrl: "views/goods/productDetail.html?"+preventCache })105        .when('/cart', { templateUrl: "views/cart/cart.html?"+preventCache })106        .when('/airport', { templateUrl: "views/order/airportSelect.html?"+preventCache })107        .when('/airport/:id', { templateUrl: "views/order/airportSelect.html?"+preventCache })108        109        110        .when('/comment/:id', { templateUrl: "views/app/comment.html?"+preventCache })111        .when('/myOrder', { templateUrl: "views/wechat/myOrder.html?"+preventCache })112        .when('/myFreeOrder', { templateUrl: "views/wechat/myFreeOrder.html?"+preventCache })113        .when('/myInfo', { templateUrl: "views/wechat/myInfo.html?"+preventCache })114        .when('/car', { templateUrl: "views/wechat/car.html?"+preventCache })115        .when('/buyFree', { templateUrl: "views/wechat/buyFree.html?"+preventCache })116        .when('/easyHandsInfo', { templateUrl: "views/wechat/easyHandsInfo.html?"+preventCache })117        .when('/easyHandsInfoSuccess', { templateUrl: "views/wechat/easyHandsInfoSuccess.html?"+preventCache })118        .when('/easyHandsDown', { templateUrl: "views/wechat/easyHandsDown.html?"+preventCache })119        .when('/easyHandsAgent', { templateUrl: "views/wechat/easyHandsAgent.html?"+preventCache })120        .when('/activity', { templateUrl: "views/wechat/activity.html?"+preventCache })121        .when('/refinedProducts', { templateUrl: "views/wechat/refinedProducts.html?"+preventCache }) 122        123        .when('/oauth2/:openId/:state', { templateUrl: "views/wechat/oauth2.html?"+preventCache })   124        .when('/wechatOauth/:state', { templateUrl: "views/wechat/wechatOauth.html?"+preventCache })125        126		127		/** add in 1.6 **/128		.when('/register', { templateUrl: "views/user/register.html?"+preventCache })129		.when('/myProfile', { templateUrl: "views/user/my.html?"+preventCache })130		.when('/myProfile/:from', { templateUrl: "views/user/my.html?"+preventCache })131		.when('/myCoupon', { templateUrl: "views/user/myCoupon.html?"+preventCache })132		.when('/myCoupon/:token', { templateUrl: "views/user/myCoupon.html?"+preventCache })133		134		.when('/myPhone', { templateUrl: "views/user/myPhone.html?"+preventCache })135		.when('/myPhone/:mobile', { templateUrl: "views/user/myPhone.html?"+preventCache })136		.when('/myPhone/:mobile/:token', { templateUrl: "views/user/myPhone.html?"+preventCache })137		.when('/activity201501', { templateUrl: "views/activity/activity201501.html?"+preventCache 138			  ,resolve: {139				load: app.asyncjs('js/controller/activity/activity.js')140			  }141		})142		.when('/wechat/myPhone', { templateUrl: "views/wechat/myPhone.html?"+preventCache })143		.when('/wechat/myWiFi', { templateUrl: "views/wechat/myWiFi.html?"+preventCache })144		.when('/wechat/myAirportInfo', { templateUrl: "views/wechat/myAirportInfo.html?"+preventCache })145		146		.when('/airportService', { templateUrl: "views/order/airportService.html?"+preventCache })147		.when('/airportServiceNew', { templateUrl: "views/order/airportServiceNew.html?"+preventCache })148		.when('/airportServiceOrder', { templateUrl: "views/order/airportServiceOrder.html?"+preventCache149			,resolve: {150				load: app.asyncjs(['lib/mobiscroll.zepto.js','lib/mobiscroll.custom-2.6.2.js'])151			}152		})153		/*for app**/154		.when('/about', { templateUrl: "views/app/about.html?"+preventCache155			,resolve: {156				load: app.asyncjs('js/controller/app/apppages.js')157			}158		 })159        .when('/about/:type', { templateUrl: "views/app/about.html?"+preventCache 160        	,resolve: {161				load: app.asyncjs('js/controller/app/apppages.js')162			}163        })164        .when('/article/:id', { templateUrl: "views/app/article.html?"+preventCache165        	,resolve: {166				load: app.asyncjs('js/controller/app/apppages.js')167			}168		})169        .when('/article/:id/:type', { templateUrl: "views/app/article.html?"+preventCache170			,resolve: {171				load: app.asyncjs('js/controller/app/apppages.js')172			}173        })174		.when('/app/wifiDetail', { templateUrl: "views/app/wifiDetail.html?"+preventCache175			,resolve: {176				load: app.asyncjs('js/controller/app/apppages.js')177			}178		 })179		.when('/service', { templateUrl: "views/app/serviceTerms.html?"+preventCache180			,resolve: {181				load: app.asyncjs('js/controller/app/apppages.js')182			}183		})184        .when('/service/:type', { templateUrl: "views/app/serviceTerms.html?"+preventCache185			,resolve: {186				load: app.asyncjs('js/controller/app/apppages.js')187			}188        })189        .when('/agent', { templateUrl: "views/app/agent.html?"+preventCache190			,resolve: {191				load: app.asyncjs('js/controller/app/apppages.js')192			}193        })194        .when('/agent/:type', { templateUrl: "views/app/agent.html?"+preventCache195			,resolve: {196				load: app.asyncjs('js/controller/app/apppages.js')197			}198        })199        .when('/carBilling', { templateUrl: "views/app/carBilling.html?"+preventCache 200			,resolve: {201				load: app.asyncjs('js/controller/app/apppages.js')202			}203        })204        .when('/carBilling/:type', { templateUrl: "views/app/carBilling.html?"+preventCache205			,resolve: {206				load: app.asyncjs('js/controller/app/apppages.js')207			}208        })209        .when('/mifi', { templateUrl: "views/app/mifi.html?"+preventCache210			,resolve: {211				load: app.asyncjs('js/controller/app/apppages.js')212			}213        })214        .when('/mifi/:type', { templateUrl: "views/app/mifi.html?"+preventCache215			,resolve: {216				load: app.asyncjs('js/controller/app/apppages.js')217			}218        })219		220		.when('/downloadApp', { templateUrl: "views/wechat/downloadApp.html?"+preventCache221			,resolve: {222				load: app.asyncjs('js/controller/app/apppages.js')223			}224		}) 225		.when('/download', { templateUrl: "views/wechat/download.html?"+preventCache226			,resolve: {227				load: app.asyncjs('js/controller/app/apppages.js')228			}229		}) 230		.when('/app/wifiAgent', { templateUrl: "views/app/wifiAgent.html?"+preventCache231			,resolve: {232				load: app.asyncjs('js/controller/app/apppages.js')233			}234		})235		.when('/app/wifiAgent_1_2', { templateUrl: "views/app/wifiAgent_1_2.html?"+preventCache236			,resolve: {237				load: app.asyncjs('js/controller/app/apppages.js')238			}239		})240		.when('/app/airportBus', { templateUrl: "views/app/airportBus.html?"+preventCache241			,resolve: {242				load: app.asyncjs('js/controller/app/apppages.js')243			}244		})245		.when('/app/shuttleService', { controller:"shuttleServiceController",templateUrl: "views/app/shuttleService.html?"+preventCache246			,resolve: {247				load: app.asyncjs('js/controller/app/apppages.js')248			}249		})250		.when('/app/tourDetail/:id', { templateUrl: "views/app/tourDetail.html?"+preventCache251			,resolve: {252				load: app.asyncjs('js/controller/app/apppages.js')253			}254		})255		/** for app*/256		.when('/update', { templateUrl: "views/update.html?"+preventCache })257		.when('/erroinfo', { templateUrl: "views/erroinfo.html?"+preventCache })258		259		/*活动 **/260		.when('/activity/activity01', { templateUrl: "views/activity/activity-01.html?"+preventCache 261			  ,resolve: {262				load: app.asyncjs('js/controller/activity/activity.js')263			  }264		})		265		.when('/activity/activityDetail', { templateUrl: "views/activity/activity201501.html?"+preventCache,controller:'activity201501Controller' 266			  ,resolve: {267				load: app.asyncjs('js/controller/activity/activity.js')268			  }269		})270		.when('/activity/activityDown', { templateUrl: "views/activity/down.html?"+preventCache,controller:'activityDownController' 271			  ,resolve: {272				load: app.asyncjs('js/controller/activity/activity.js')273			  }274		})275		276		.when('/activity/xrhl', { templateUrl: "views/activity/xrhl.html?"+preventCache 277			  ,resolve: {278				load: app.asyncjs('js/controller/activity/activity.js')279			  }280		})281		.when('/activity/xrhlnew', { templateUrl: "views/activity/xrhlnew.html?"+preventCache 282			  ,resolve: {283				load: app.asyncjs('js/controller/activity/activity.js')284			  }285		})286		.when('/activity/full', { templateUrl: "views/activity/full.html?"+preventCache 287			  ,resolve: {288				load: app.asyncjs('js/controller/activity/activity.js')289			  }290		})291		.when('/activity/guide', { templateUrl: "views/activity/guide.html?"+preventCache 292			  ,resolve: {293				load: app.asyncjs('js/controller/activity/activity.js')294			  }295		})296		.when('/activity/half', { templateUrl: "views/activity/half.html?"+preventCache 297			  ,resolve: {298				load: app.asyncjs('js/controller/activity/activity.js')299			  }300		})301		.when('/activity/xbl', { templateUrl: "views/activity/xbl.html?"+preventCache 302			  ,resolve: {303				load: app.asyncjs('js/controller/activity/activity.js')304			  }305		})306		.when('/taxFreeStore', { templateUrl: "views/activity/taxFreeStore.html?"+preventCache })307		308		.when('/activity/activityDetail/:id', { templateUrl: "views/activity/activity201501.html?"+preventCache,controller:'activity201501Controller' 309			  ,resolve: {310				load: app.asyncjs('js/controller/activity/activity.js')311			  }312		})313		.when('/activity/activityDetail/:id/:type', { templateUrl: "views/activity/activityDetail.html?"+preventCache,controller:'activityDetailController' 314			  ,resolve: {315				load: app.asyncjs('js/controller/activity/activity.js')316			  }317		})318		.when('/activity/mothersDay', { templateUrl: "views/activity/mothersDay.html?"+preventCache 319			  ,resolve: {320				load: app.asyncjs('js/controller/activity/activity.js')321			  }322		})323		.when('/activity/beautySummer', { templateUrl: "views/activity/beautySummer.html?"+preventCache 324			  ,resolve: {325				load: app.asyncjs('js/controller/activity/activity.js')326			  }327		})328		.when('/activity/may', { templateUrl: "views/activity/may.html?"+preventCache 329			  ,resolve: {330				load: app.asyncjs('js/controller/activity/activity.js')331			  }332		})333		.when('/activity/xblnew', { templateUrl: "views/activity/xblnew.html?"+preventCache 334			  ,resolve: {335				load: app.asyncjs('js/controller/activity/activity.js')336			  }337		})338		.when('/activity/groupBuy', { templateUrl: "views/activity/groupBuy.html?"+preventCache339			  ,resolve: {340				load: app.asyncjs('js/controller/activity/activity.js')341			  }342		 })343		.when('/activity/tour', { templateUrl: "views/activity/tour.html?"+preventCache344			  ,resolve: {345				load: app.asyncjs('js/controller/activity/activity.js')346			  }347		})348		.when('/activity/tangcun', { templateUrl: "views/activity/tangcun.html?"+preventCache349			  ,resolve: {350				load: app.asyncjs('js/controller/activity/activity.js')351			  }352		})353		.when('/activity/beautyLife', { templateUrl: "views/activity/beautyLife.html?"+preventCache354			  ,resolve: {355				load: app.asyncjs('js/controller/activity/activity.js')356			  }357		})358		.when('/activity/twGift', { templateUrl: "views/activity/twGift_2.html?"+preventCache359			  ,resolve: {360				load: app.asyncjs('js/controller/activity/activityDown.js')361			  }362		})363		.when('/activity/twGift_3', { templateUrl: "views/activity/twGift_3.html?"+preventCache364			  ,resolve: {365				load: app.asyncjs('js/controller/activity/activityDown.js')366			  }367		})368		.when('/activity/twGift_4', { templateUrl: "views/activity/twGift_4.html?"+preventCache369			  ,resolve: {370				load: app.asyncjs('js/controller/activity/activityDown.js')371			  }372		})373		.when('/activity/autumn', { templateUrl: "views/activity/autumn.html?"+preventCache374			  ,resolve: {375				load: app.asyncjs('js/controller/activity/activityDown.js')376			  }377		})378		.when('/activity/nationalDay', { templateUrl: "views/activity/nationalDay.html?"+preventCache379			  ,resolve: {380				load: app.asyncjs('js/controller/activity/fullGive.js')381			  }382		})383		.when('/activity/gyy', { templateUrl: "views/activity/gyy.html?"+preventCache384			  ,resolve: {385				load: app.asyncjs('js/controller/activity/fullGive.js')386			  }387		})388		/* 活动 ***/389		.otherwise({390            redirectTo: '/products'391        });392});393app.service('analytics', [394    '$rootScope', '$window', '$location', function ($rootScope, $window, $location) {395        var send = function (evt, data) {396            ga('send', evt, data);397        }398    }399]);400app.run( function($rootScope, $location) {    401    $rootScope.$on("$routeChangeStart", function(event, next, current) {402    	$rootScope.winWidth=$(window).width();403    	$rootScope.winHeight=$(window).height();404    	var tokenInfo=getToken();405    	if(tokenInfo){406    		if(!tokenInfo.openId){407    			removeToken();408    		}409    	}410        if(next.templateUrl && onlyWechatOauth[next.templateUrl.split('?')[0]]){411            if(!$rootScope.isOauth2 && next.templateUrl!="views/wechat/oauth2.html" && easybuy.isWechat && !(getToken() && getToken().token && getToken().mobile && getToken().mobile.length>6)){412                var state=onlyWechatOauth[next.templateUrl.split('?')[0]];413                if(isNotBindPhone[state]==true &&(getToken() && getToken().token)){414                }else{415                	if(isContainFind[state]){416                		setFind($location.search());417                	}418                	$location.path("/wechatOauth/"+state);419                }                420            }421        } 422        if(next.templateUrl){423            if(next.templateUrl=="views/activity/activity-01.html"){424                $rootScope.goeasy="台湾直购,正品低价,万元红包等你来抢!!";                425            }else{426                $rootScope.goeasy="购轻松";                427            }428        }429        if(current && current.loadedTemplateUrl && current.loadedTemplateUrl=="views/activity/activity-01.html"){430            location.reload(); 431        }432        $(document).attr("title",$rootScope.goeasy); 433        hideLoading();                          434    });435});436app.controller('erroinfoController',function($rootScope, $window, $scope, httpRequest,dataStringify, analytics){437	setTimeout(function(){438		window.location.href="#/products"439	},1000);440});441app.controller('mainController', function ($rootScope, $window, $scope, httpRequest,dataStringify, analytics) {442    $rootScope.goeasy="购轻松";443	444	$rootScope.categoryId=0;445	$rootScope.categoryIndex=1;446	$rootScope.categoryCount=1;447	$rootScope.initNav=function(cat){448		449        $("#scroller2ul").html("");450        var actived="border-bottom: 3px solid #F14F57;color:#F14F57;";451        var lis=$rootScope.categoryId==0?"<li style=\""+actived+"\">" : "<li style=\"\">";452        lis=lis+"<a href=\"#/products\">首页</a></li>";453        var liCount=1;454        $rootScope.categoryIndex=1;455        for(var i=0;i<cat.length;i++){456            if(cat[i].name.indexOf('台湾必买')==-1){457            	if($rootScope.categoryId==cat[i].code){458					lis=lis+"<li style=\""+actived+"\"><a href=\"#/products/"+cat[i].code+"\">"+cat[i].name+" </a></li>";459            		$rootScope.categoryIndex=i+2;460            	}else{461            		lis=lis+"<li><a href=\"#/products/"+cat[i].code+"\">"+cat[i].name+" </a></li>";462            	}463                liCount++;464            }465        }466        $rootScope.categoryCount=liCount;467        $("#scroller2ul").html(lis);468        $("#scroller2").css("width",liCount*25+"%");469        $("#scroller2ul").css("width",liCount*25+"%");470        $("#scroller2ul li").css("width",100/liCount+"%");471        var generateScroll=function(){472        	var myScroll = new IScroll('#wrapper2', 473			 { 474				eventPassthrough: true, 475				scrollX: true, 476				scrollY: false,477				 preventDefault: false478			 });479			 var mod=parseInt($rootScope.categoryIndex/4);480			 var offset=$("#scroller2ul li").width()*mod;481			 //myScroll.scrollerStyle['transform'] = 'translate(-'+offset+'px,0px)translateZ(0)';482			483			if(cat.length>3){484				myScroll.scrollTo(-offset, 0);485			 }486			 //myScroll.scrollTo(100, 0, 500, 'quadratic')487        };488        if(typeof(IScroll)=="undefined"){489            $.ajax({490                url: '/lib/iscroll.js',491                dataType: "script",492                cache:true,493                success: function(data){494                    generateScroll();495                }496            });497        }else{498            generateScroll();499        }500    };501    $rootScope.$on("$routeChangeStart", function (event, next, current) {502        if(next.templateUrl && (next.templateUrl!="views/wechat/wechatOauth.html" || next.templateUrl!="views/wechat/oauth2.html")){503            $rootScope.loading = true;504        }else{505            $rootScope.loading = true;506        }507        if(location.hash.indexOf('activityDown')>-1 || location.hash.indexOf('activityDetail')>-1){508			//window.location.href="#/erroinfo";509		}510        	       511    });512	513    $rootScope.$on("$routeChangeSuccess", function (a,b) {514        $rootScope.loading = false;515    });	 516    $scope.audioControls=$("#audioControls")[0];    517    $rootScope.hideOverlay=function(){518    	$rootScope.loading = false;    	519    };520    $scope.initPlay=function(){521    	if(location.hash=="" || location.hash=="#/products"){522    		var ctr=$scope.audioControls;523    		ctr.play();524    	}    	525    };526    $scope.play=function(){527    	var ctr=$scope.audioControls;528    	//alert(ctr.paused);529    	if(ctr.paused){530    		ctr.play();531    		$("#div-nav-music-controls").removeClass("div-nav-music-pause");532    		$("#div-nav-music-controls").addClass("div-nav-music");533    	}else{534    		ctr.pause();535    		$("#div-nav-music-controls").removeClass("div-nav-music");536    		$("#div-nav-music-controls").addClass("div-nav-music-pause");537    	}    	538    };539    $scope.imageServiceUrl = imageServiceUrl;540    $rootScope.isOauth2=false;541    $rootScope.oauth2=function(state,type){  542        $window.location=webchatOauth(state,type);543        return;544    };545    httpRequest.APIPOST('/goods/category_v1.3', dataStringify("platform=all"), { "content-type": "application/x-www-form-urlencoded" }).then(function (result) {546		if (result && result.code == statusCode.Success) {547			var cat=result.result;			548			$rootScope.categories=cat;//.slice(1);549		}else{ 550			alertWarning(result.msg);551		}552	});...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1/* eslint-env mocha */2const assert = require("assert");3const fs = require("fs");4const path = require("path");5const rollup = require("rollup");6const {withDir} = require("tempdir-yaml");7const {default: endent} = require("endent");8const sinon = require("sinon");9const cjsEs = require("..");10async function bundle(file, options, rollupOptions = {}) {11  const warns = [];12  const systemWarns = [];13  const bundle = await rollup.rollup({14    input: [file],15    plugins: [16      cjsEs(Object.assign({cache: false, nested: true}, options))17    ],18    onwarn(warn) {19      if (warn.code === "PLUGIN_WARNING") {20        warns.push(warn);21      } else {22        systemWarns.push(warn);23      }24    },25    ...rollupOptions26  });27  const modules = bundle.cache.modules.slice();28  const result = await bundle.generate({29    format: "es",30    freeze: false,31    sourcemap: true32  });33  result.warns = warns;34  result.systemWarns = systemWarns;35  result.modules = modules;36  result.namedOutput = result.output.reduce(37    (o, output) => {38      o[output.fileName] = output;39      return o;40    },41    {}42  );43  result.namedModules = result.modules.reduce(44    (o, m) => {45      o[m.id.match(/[^\\/]+$/)[0]] = m;46      return o;47    },48    {}49  );50  return result;51}52describe("main", () => {53  it("warn unconverted require", () =>54    withDir(`55      - entry.js: |56          const r = require;57          r("foo");58    `, async resolve => {59      const {warns} = await bundle(resolve("entry.js"));60      assert.equal(warns.length, 1);61      assert(/Unconverted `require`/.test(warns[0].message));62      assert.equal(warns[0].pos, 10);63    })64  );65});66describe("exportType option", () => {67  it("named", () =>68    withDir(`69      - entry.js: |70          const foo = require("foo");71          module.exports = {foo};72    `, async resolve => {73      const {namedOutput: output} = await bundle(resolve("entry.js"));74      const {namedOutput: output2} = await bundle(resolve("entry.js"), {exportType: "named"});75      assert.equal(output["entry.js"].code, output2["entry.js"].code);76      assert.equal(output["entry.js"].code.trim(), endent`77        import * as foo from 'foo';78        export { foo };79      `);80    })81  );82  83  it("default", () =>84    withDir(`85      - entry.js: |86          const foo = require("foo");87          module.exports = {foo};88    `, async resolve => {89      const {namedOutput: output} = await bundle(resolve("entry.js"), {exportType: "default"});90      assert.equal(output["entry.js"].code.trim(), endent`91        import foo from 'foo';92        93        var entry = {foo};94        95        export default entry;96      `);97    })98  );99  100  it("function", () =>101    withDir(`102      - entry.js: |103          const foo = require("./foo");104          module.exports = {foo};105      - foo.js: |106          module.exports = {107            foo: "FOO"108          };109    `, async resolve => {110      const exportType = sinon.spy(id => {111        if (id.endsWith("entry.js")) {112          return "named";113        }114        return "default";115      });116      const {namedOutput: output} = await bundle(resolve("entry.js"), {exportType});117      assert.equal(exportType.callCount, 2);118      assert.equal(output["entry.js"].code.trim(), endent`119        var foo = {120          foo: "FOO"121        };122        123        export { foo };124      `);125    })126  );127    128  it("object map", () =>129    withDir(`130      - entry.js: |131          const foo = require("./foo");132          module.exports = {foo};133      - foo.js: |134          module.exports = {135            foo: "FOO"136          };137    `, async resolve => {138      const exportType = {139        [resolve("entry.js")]: "default",140        [resolve("foo.js")]: "named"141      };142      const {namedOutput: output} = await bundle(resolve("entry.js"), {exportType});143      assert.equal(output["entry.js"].code.trim(), endent`144        const _export_foo_ = "FOO";145        146        var foo = {147          __proto__: null,148          foo: _export_foo_149        };150        151        var entry = {foo};152        153        export default entry;154      `);155    })156  );157});158describe("unmatched import/export style and cache", () => {159  // warn users if the import style doesn't match the actual exports160  it("warn if import names and importee exports default", () =>161    withDir(`162      - entry.js: |163          const foo = require("./foo");164      - foo.js: |165          module.exports = "foo";166    `, async resolve => {167      let warns;168      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));169      assert.equal(warns.length, 1);170      assert(/foo\.js.*? doesn't export names expected by .*?entry\.js/.test(warns[0].message));171      172      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));173      assert.equal(warns.length, 0);174      175      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));176      assert.equal(warns.length, 0);177    })178  );179  180  it("warn if import names and importee exports default (force)", () =>181    withDir(`182      - entry.js: |183          import {foo} from "./foo.js";184      - foo.js: |185          module.exports = "foo";186    `, async resolve => {187      let warns;188      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));189      assert.equal(warns.length, 1);190      assert(/foo\.js.*? doesn't export names expected by .*?entry\.js/.test(warns[0].message));191      192      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));193      assert.equal(warns.length, 1);194      195      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));196      assert.equal(warns.length, 1);197    })198  );199  200  it("don't warn with bare import", () =>201    withDir(`202      - entry.js: |203          import "./foo.js";204      - foo.js: |205          module.exports = "foo";206    `, async resolve => {207      let warns;208      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));209      assert.equal(warns.length, 0);210    })211  );212  213  it("don't warn with bare import (cjs)", () =>214    withDir(`215      - entry.js: |216          require("./foo");217      - foo.js: |218          module.exports = "foo";219    `, async resolve => {220      let warns;221      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));222      assert.equal(warns.length, 0);223    })224  );225  226  it("don't warn with bare import (cjs + name)", () =>227    withDir(`228      - entry.js: |229          require("./foo");230      - foo.js: |231          exports.foo = "foo";232    `, async resolve => {233      let warns;234      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));235      assert.equal(warns.length, 0);236    })237  );238  239  it("import default if others import default", () =>240    withDir(`241      - entry.js: |242          const foo = require("./foo");243          require("./bar");244      - foo.js: |245          module.exports = {246            foo: "foo"247          };248      - bar.js: |249          import foo from "./foo";250    `, async resolve => {251      let warns;252      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));253      assert.equal(warns.length, 1);254      255      assert.equal(warns[0].pluginCode, "CJS_ES_MISSING_EXPORT");256      assert.equal(warns[0].importer, resolve("bar.js"));257      assert.equal(warns[0].importerExpect, "default");258      assert.equal(warns[0].exporter, resolve("foo.js"));259      260      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));261      assert.equal(warns.length, 0);262      263      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));264      assert.equal(warns.length, 0);265    })266  );267  268  it("import default if the name is missing and the name is an object method", () =>269    withDir(`270      - entry.js: |271          const foo = require("./foo");272          console.log(foo.hasOwnProperty("foo"));273      - foo.js: |274          module.exports = {275            foo: "foo"276          };277    `, async resolve => {278      let systemWarns;279      ({systemWarns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));280      assert.equal(systemWarns.length, 1);281      282      assert.equal(systemWarns[0].code, "MISSING_EXPORT");283      assert.equal(path.resolve(systemWarns[0].importer), resolve("entry.js"));284      assert.equal(systemWarns[0].missing, "hasOwnProperty");285      assert.equal(path.resolve(systemWarns[0].exporter), resolve("foo.js"));286      287      ({systemWarns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));288      assert.equal(systemWarns.length, 0);289      290      ({systemWarns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));291      assert.equal(systemWarns.length, 0);292    })293  );294  295  it("warn if import default and importee export names (bad config)", () =>296    withDir(`297      - entry.js: |298          const foo = require("./foo");299      - foo.js: |300          export const foo = "foo";301    `, async resolve => {302      const exportType = (id) => id.endsWith("foo.js") ? "default" : null;303      let warns;304      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache"), exportType}));305      assert.equal(warns.length, 1);306      assert(/foo\.js' doesn't export default expected by .*?entry\.js/.test(warns[0].message));307      308      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache"), exportType}));309      assert.equal(warns.length, 1);310      311      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));312      assert.equal(warns.length, 0);313      314      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));315      assert.equal(warns.length, 0);316    })317  );318  319  it("import default but others import names (bad config)", () =>320    withDir(`321      - entry.js: |322          const foo = require("./foo");323          require("./bar");324      - foo.js: |325          module.exports = {foo: "foo"};326      - bar.js: |327          import {foo} from "./foo";328    `, async resolve => {329      const exportType = (id) => id.endsWith("foo.js") ? "default" : null;330      let warns;331      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache"), exportType}));332      assert.equal(warns.length, 1);333      334      assert.equal(warns[0].pluginCode, "CJS_ES_MISSING_EXPORT");335      assert.equal(warns[0].importer, resolve("bar.js"));336      assert.equal(warns[0].importerExpect, "names");337      assert.equal(warns[0].exporter, resolve("foo.js"));338      339      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache"), exportType}));340      assert.equal(warns.length, 1);341      342      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));343      assert.equal(warns.length, 0);344      345      ({warns} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")}));346      assert.equal(warns.length, 0);347    })348  );349  350  it("no warning if exporter exports both", () =>351    withDir(`352      - entry.js: |353          require("./foo");354          require("./bar");355      - foo.js: |356          export function foo() {}357          export default "foo";358      - bar.js: |359          const {foo} = require("./foo");360    `, async resolve => {361      {362        const {warns, modules} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")});363        assert.equal(warns.length, 0);364        const bar = modules.find(m => m.id.endsWith("bar.js"));365        assert.equal(bar.code.trim(), endent`366          import {foo} from "./foo";367        `);368      }369      // another run with cache370      {371        const {warns, modules} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")});372        assert.equal(warns.length, 0);373        const bar = modules.find(m => m.id.endsWith("bar.js"));374        assert.equal(bar.code.trim(), endent`375          import {foo} from "./foo";376        `);377      }378    })379  );380  381  it("no warning if exporter exports both (unmatched import)", () =>382    withDir(`383      - entry.js: |384          require("./bar");385          require("./bak");386      - foo.js: |387          export const foo = "foo";388          export default () => {};389      - bar.js: |390          const {foo} = require("./foo");391      - baz.js: |392          const foo = require("./foo");393          foo();394      - bak.js: |395          require("./baz"); // make rollup loads baz.js after bar.js396    `, async resolve => {397      {398        const {warns, modules} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")});399        assert.equal(warns.length, 0);400        401        const bar = modules.find(m => m.id.endsWith("bar.js"));402        assert.equal(bar.code.trim(), endent`403          import {foo} from "./foo";404        `);405      }406      // another run with cache, make sure bar.js is not affected by the cache.407      {408        const {warns, modules} = await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")});409        assert.equal(warns.length, 0);410        411        const bar = modules.find(m => m.id.endsWith("bar.js"));412        assert.equal(bar.code.trim(), endent`413          import {foo} from "./foo";414        `);415      }416    })417  );418  419  it("warn not-loaded modules", () =>420    withDir(`421      - entry.js: |422          const foo = require("foo");423          require("./bar");424      - bar.js: |425          const foo = require("foo");426          foo();427    `, async resolve => {428      const {warns} = await bundle(resolve("entry.js"));429      assert.equal(warns.length, 1);430      assert.equal(warns[0].pluginCode, "CJS_ES_NOT_LOADED");431      assert.equal(warns[0].moduleId, "foo");432    })433  );434  435  it("ignore externals", () =>436    withDir(`437      - entry.js: |438          const foo = require("foo");439          require("./bar");440      - bar.js: |441          const foo = require("foo");442          foo();443    `, async resolve => {444      const {warns} = await bundle(resolve("entry.js"), {}, {external: ["foo"]});445      assert.equal(warns.length, 0);446    })447  );448  449  it("the cache is ordered", () =>450    withDir(`451      - entry.js: |452          require("./foo");453          require("./bar");454      - foo.js: |455          module.exports = "foo";456      - bar.js: |457          module.exports = "bar";458    `, async resolve => {459      await bundle(resolve("entry.js"), {cache: resolve(".cjsescache")});460      const cache = JSON.parse(fs.readFileSync(resolve(".cjsescache"), "utf8"));461      assert(cache[0].endsWith("bar.js"));462      assert(cache[1].endsWith("foo.js"));463    })464  );465});466describe("export table", () => {467  // use export table to decide export style468  it("export default if others import default", () =>469    withDir(`470      - entry.js: |471          import foo from "./foo";472      - foo.js: |473          exports.foo = "foo";474    `, async resolve => {475      const {warns, namedModules} = await bundle(resolve("entry.js"));476      assert.equal(warns.length, 0);477      assert(/export .+ as default/.test(namedModules["foo.js"].code));478    })479  );480  481  it("export names if other import names", () =>482    // FIXME: since cjs-es export names by default, should we drop this test?483    withDir(`484      - entry.js: |485          import {foo} from "./foo";486      - foo.js: |487          exports.foo = "foo";488    `, async resolve => {489      const {warns, namedModules} = await bundle(resolve("entry.js"));490      assert.equal(warns.length, 0);491      assert(/export .+ as foo/.test(namedModules["foo.js"].code));492    })493  );...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1angular.module( 'symantis.me', [2	'symantis.me.connections',3	'symantis.me.settings',4	'symantis.me.manti',5	'symantis.me.information'6])7.config(function config($stateProvider, $urlRouterProvider ) {8	9	//$urlRouterProvider.when('/*me', '/login');	10	$stateProvider11		.state( 'me', {12			url: '/me',13			resolve : {14				//cache: 'cache',15			    user: function($rootScope, UserDS){16          			//return $rootScope.user = UserDS.find($rootScope.currentUser.id);17		    		return $rootScope.currentUser;18		    	},19		    	/*20			    user : function($rootScope) {21			        return $rootScope.user = $rootScope.currentUser;22			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);23			    },24			    25			    users: function($rootScope) {26			    	return $rootScope.users;27			    }28			    */29		    },30			views: {31				"main": {32					controller: 'MeCtrl',33					templateUrl: 'me/index.tpl.html'34				},35				"sitenav": {36					controller: 'SiteNavCtrl',37	                templateUrl: 'sitenav/index.tpl.html'38				},39				"header": {40					controller: 'HeaderCtrl',41	                templateUrl: 'header/header.tpl.html'42				},43				"footer": {44					controller: 'FooterCtrl',45	                templateUrl: 'footer/index.tpl.html'46				},47				"subheader@me": {48					controller: 'MeHeaderCtrl',49                	templateUrl: 'me/header.tpl.html'50				},51				"leftside@me": {52					controller: 'MeLeftsideCtrl',53					templateUrl: 'me/leftside.tpl.html'54				}55			}56		})57		.state( 'me.connections', {58			url: '/connections',59			views: {60				"main@": {61					controller: 'ConnectionsCtrl',62					templateUrl: 'me/connections/index.tpl.html'63				},64				"leftside@me.connections": {65					controller: 'MeConnectionsLeftsideCtrl',66                	templateUrl: 'me/connections/leftside.tpl.html'67				}68			}69		})70		.state( 'me.manti', {71			url: '/manti',72			resolve: {73				mantis : function($rootScope) {74				       return $rootScope.mantis;75				},    76			    user : function($rootScope) {77			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);78			        return  $rootScope.currentUser;79			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);80			    },81			    users: function($rootScope) {82			    	return $rootScope.users;83			    }84			},85			views: {86				"main@": {87					controller: 'MantiCtrl',88					templateUrl: 'me/manti/index.tpl.html'89				},90				"leftside@me.manti": {91					controller: 'MeMantiLeftsideCtrl',92                	templateUrl: 'me/manti/leftside.tpl.html'93				},94				"manti-nav@me.manti": {95					controller: 'MeMantiNavCtrl',96                	templateUrl: 'me/manti/sort.tpl.html'97				}98			}99		})100		.state( 'me.manti.view', {101			url: '/:id/:title',102			resolve: {103				manti : function($stateParams) {104				    return { id: $stateParams.id, clean: $stateParams.title };105				},    106			    user : function($rootScope) {107			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);108			        return $rootScope.currentUser;109			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);110			    },111			    users: function($rootScope) {112			    	return $rootScope.users;113			    }114			},115			views: {116				"manti@me.manti": {117					controller: 'MantiViewCtrl',118					templateUrl: 'me/manti/view.tpl.html'119				},120				"manti-nav@me.manti": {121					controller: 'MeMantiNavCtrl',122                	templateUrl: 'common/back.tpl.html'123				}124			}125		})126		.state( 'me.settings', {127			url: '/settings',128			resolve: {   129			    user : function($rootScope) {130			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);131			        return $rootScope.currentUser;132			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);133			    },134			    users: function($rootScope) {135			    	return $rootScope.users;136			    }137			},138			views: {139				"main@": {140					controller: 'MeSettingsCtrl',141					templateUrl: 'me/settings/index.tpl.html'142				},143				"leftside@me.settings": {144					controller: 'MeSettingsLeftsideCtrl',145                	templateUrl: 'me/settings/leftside.tpl.html'146				}147			}148		})149		.state('me.settings.account',{150			url: '/account',151			resolve: {   152			    user : function($rootScope) {153			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);154			        return $rootScope.currentUser;155			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);156			    },157			    users: function($rootScope) {158			    	return $rootScope.users;159			    }160			},161			views: {162				"settings@me.settings": {163					controller: 'MeSettingsAccountCtrl',164					templateUrl: 'me/settings/account.tpl.html'165				}166			}167		})168		.state('me.settings.emails',{169			url: '/emails',170			resolve: {   171			    user : function($rootScope) {172			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);173			        return $rootScope.currentUser;174			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);175			    },176			    users: function($rootScope) {177			    	return $rootScope.users;178			    }179			},180			views: {181				"settings@me.settings": {182					controller: 'MeSettingsEmailsCtrl',183					templateUrl: 'me/settings/emails.tpl.html'184				}185			}186		})187		.state('me.settings.notifications',{188			url: '/notifications',189			resolve: {   190			    user : function($rootScope) {191			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);192			        return $rootScope.currentUser;193			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);194			    },195			    users: function($rootScope) {196			    	return $rootScope.users;197			    }198			},199			views: {200				"settings@me.settings": {201					controller: 'MeSettingsNotificationsCtrl',202					templateUrl: 'me/settings/notifications.tpl.html'203				}204			}205		})206		.state('me.settings.security',{207			url: '/security',208			resolve: {   209			    user : function($rootScope) {210			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);211			        return $rootScope.currentUser;212			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);213			    },214			    users: function($rootScope) {215			    	return $rootScope.users;216			    }217			},218			views: {219				"settings@me.settings": {220					controller: 'MeSettingsSecurityCtrl',221					templateUrl: 'me/settings/security.tpl.html'222				}223			}224		})225		.state('me.settings.manti',{226			url: '/manti',227			resolve: {   228			    user : function($rootScope) {229			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);230			        return $rootScope.currentUser;231			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);232			    },233			    users: function($rootScope) {234			    	return $rootScope.users;235			    }236			},237			views: {238				"settings@me.settings": {239					controller: 'MeSettingsMantiCtrl',240					templateUrl: 'me/settings/manti.tpl.html'241				}242			}243		})244		.state('me.settings.sykit',{245			url: '/sykit',246			resolve: {   247			    user : function($rootScope) {248			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);249			        return $rootScope.currentUser;250			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);251			    },252			    users: function($rootScope) {253			    	return $rootScope.users;254			    }255			},256			views: {257				"settings@me.settings": {258					controller: 'MeSettingsSykitCtrl',259					templateUrl: 'me/settings/sykit.tpl.html'260				}261			}262		})263		.state( 'me.information', {264			url: '/information',265			resolve: {   266			    user : function($rootScope) {267			        //return $rootScope.user = UserDS.find($rootScope.currentUser.id);268			        return $rootScope.currentUser;269			        //return $rootScope.user = cache.resolveUserCache($rootScope.users, $rootScope.currentUser.handle);270			    },271			    users: function($rootScope) {272			    	return $rootScope.users;273			    }274			},275			views: {276				"main@": {277					controller: 'InformationCtrl',278					templateUrl: 'me/information/index.tpl.html'279				},280				"leftside@me.information": {281					controller: 'MeInformationLeftsideCtrl',282                	templateUrl: 'me/information/leftside.tpl.html'283				}284			}285		})286	;287})288.controller( 'MeCtrl', function ProfileController( $scope, titleService, $http, utils, UserDS ) {289	titleService.setTitle('Me');290	$scope.$parent.toDo = ['Format Activity', 'Add Cache feature'];291	292	//$scope.user = user;293	294	//$scope.loadingSection = true;295	296	//UserDS.find(user.id).then(function(){297		$scope.loadingSection = false;298		//UserDS.bindOne($rootScope, 'user', user.id);299	//});300	301	302	/*303	$scope.loadingSection = true;304	cache.resolveUserCache($rootScope.users, user.handle).then(function(user){305		$rootScope.user = user;306		$rootScope.user.reciprocal = utils.findUserMatches($scope.user.toConnections, $scope.user.fromConnections ).length;307		$scope.loadingSection = false;308		309	});310	*/311	//$scope.user.reciprocal = utils.findUserMatches($scope.user.toConnections, $scope.user.fromConnections ).length;312	//$scope.user.totalToConnections = $scope.user.totalToConnections - $scope.user.reciprocal;313	//$scope.user.totalFromConnections = $scope.user.totalFromConnections - $scope.user.reciprocal;314	$scope.loadTags = function(query) {315		return $http.get('/api/tags/' + query);316	};317	/*318	$scope.updateUser = function (){319		console.log($scope.currentUser);320		UserModel.update($scope.currentUser)321		.then(function(model){322			console.log(model);323		});324	325	}326	*/327	328})329.controller( 'MeHeaderCtrl', function MeHeaderController( $scope, titleService ) {330	//titleService.setTitle('About');331})332.controller( 'MeLeftsideCtrl', function MeLeftsideController( $scope ) {333	//titleService.setTitle('About');...

Full Screen

Full Screen

repairs.js

Source:repairs.js Github

copy

Full Screen

1'use strict';2module.factory('RepairService', ['$rootScope', '$http', '$q', '$cookies', 'URLS', 'ShareService', 'CarService', function ($rootScope, $http, $q, $cookies, URLS, ShareService, CarService) {3    var service = 'repairs';4    var cache = {};5    return {6        get: function (p, q) {7            var key = URLS.model(service).all8                + ('?p=' + p)9                + (q['car'] ? '&car=' + q['car'] : '')10                + (q['work'] ? '&work=' + q['work'] : '')11                + (q['title'] ? '&title=' + q['title'] : '')12                + (q['lp'] ? '&lp=' + q['lp'] : '')13                + (q['hp'] ? '&hp=' + q['hp'] : '')14                + (q['rating'] ? '&rating=' + q['rating'] : '')15                + (q['shop'] ? '&shop=' + q['shop'] : '')16                + (q['limit'] ? '&limit=' + q['limit'] : '');17            return $q(function (resolve, reject) {18                if (cache[key]) {19                    resolve(cache[key]);20                }21                else {22                    $http.get(key).then(function (res) {23                        cache[key] = res.data;24                        resolve(res.data);25                    }).catch(function (res) {26                        reject(res);27                    });28                }29            });30        },31        getByShop: function (p, q) {32            var key = URLS.model(service).all + '/shop'33                + ('?p=' + p)34                + (q['shop'] ? '&shop=' + q['shop'] : '')35                + (q['limit'] ? '&limit=' + q['limit'] : '');36            return $q(function (resolve, reject) {37                if (cache[key]) {38                    resolve(cache[key]);39                }40                else {41                    $http.get(key).then(function (res) {42                        cache[key] = res.data;43                        resolve(res.data);44                    }).catch(function (res) {45                        reject(res);46                    });47                }48            });49        },50        getById: function (id) {51            return $q(function (resolve, reject) {52                var key = URLS.model(service).one.replace('{id}', id);53                if (cache[key]) {54                    resolve(cache[key]);55                }56                else {57                    $http.get(key).then(function (res) {58                        cache[key] = res.data.data;59                        resolve(res.data.data);60                    }).catch(function (res) {61                        reject(res);62                    });63                }64            });65        },66        create: function (model) {67            return $q(function (resolve, reject) {68                $http.post(URLS.model(service).all, model).then(function (res) {69                    cache = {};70                    ShareService.clearCache();71                    resolve(res.data);72                }).catch(reject);73            });74        },75        update: function (model) {76            return $q(function (resolve, reject) {77                $http.patch(URLS.model(service).all, model).then(function (res) {78                    cache = {};79                    ShareService.clearCache();80                    resolve(res.data.data);81                }).catch(reject);82            });83        },84        delete: function (id) {85            return $q(function (resolve, reject) {86                $http.delete(URLS.model(service).one.replace('{id}', id)).then(function (res) {87                    cache = {};88                    ShareService.clearCache();89                    resolve(res.data)90                }).catch(reject);91            });92        },93        getPreviousShop: function (carId) {94            return $q(function (resolve, reject) {95                var key = URLS.model(service).shops + '?car=' + carId;96                if (cache[key]) {97                    resolve(cache[key]);98                }99                else {100                    $http.get(key).then(function (res) {101                        cache[key] = res.data;102                        resolve(res.data);103                    }).catch(reject);104                }105            });106        },107        uploadImage: function (model) {108            return $q(function (resolve, reject) {109                $http.post(URLS.model(service).image, model).then(function (res) {110                    cache = {};111                    ShareService.clearCache();112                    CarService.removeCache();113                    resolve(res.data)114                }).catch(reject);115            });116        },117        deleteImage: function (model) {118            return $q(function (resolve, reject) {119                $http.delete(URLS.model(service).image_id.replace('{id}', model.id)).then(function (res) {120                    cache = {};121                    ShareService.clearCache();122                    CarService.removeCache();123                    resolve(res.data)124                }).catch(reject);125            });126        },127        saveImage: function (model) {128            return $q(function (resolve, reject) {129                $http.patch(URLS.model(service).image, model).then(function (res) {130                    cache = {};131                    ShareService.clearCache();132                    resolve(res.data)133                }).catch(reject);134            });135        },136        clearCache: function () {137            cache = {};138        },139        getAdmin: function (p, q) {140            var key = URLS.model(service).admin_all141                + ('?p=' + p)142                + (q['q'] ? '&q=' + q['q'] : '')143                + ('&limits=' + q['limits'])144                + (q['work'] ? '&work=' + q['work'] : '')145                + (q['province'] ? '&province=' + q['province'] : '')146                + (q['months'] ? '&months=' + q['months'] : '')147                + (q['year'] ? '&year=' + q['year'] : '')148                + (q['lp'] ? '&lp=' + q['lp'] : '')149                + (q['hp'] ? '&hp=' + q['hp'] : '')150                + (q['rating'] ? '&rating=' + q['rating'] : '')151                + (q['hasimage'] ? '&hasimage=' + q['hasimage'] : '')152                + (q['sort_column'] ? '&sort_column=' + q['sort_column'] : '')153                + (q['sort_order'] ? '&sort_order=' + q['sort_order'] : '')154                ;155            return $q(function (resolve, reject) {156                if (cache[key]) {157                    //resolve(cache[key]);158                }159                //else {160                $http.get(key).then(function (res) {161                    cache[key] = res.data;162                    resolve(res.data);163                }).catch(function (res) {164                    reject(res);165                });166                //}167            });168        }169    };...

Full Screen

Full Screen

index.spec.js

Source:index.spec.js Github

copy

Full Screen

...15}16describe('keshi', () => {17  const cache = createCache();18  it('can create and return a simple non-expiring cache item', async () => {19    await cache.resolve('hello', 'world');20    const value = await cache.resolve('hello');21    expect(value).to.be('world');22  });23  it('resolves new value from cache after expiry time', async () => {24    const cacheFn = () => cache.resolve('asyncItem', () => Math.random(), '200 ms');25    const firstValue = await cacheFn();26    const cachedValueBefore = await cacheFn();27    expect(firstValue).to.eql(cachedValueBefore);28    return timeout(async () => {29      const cachedValueAfter = await cacheFn();30      expect(firstValue).to.not.eql(cachedValueAfter);31    }, 300);32  });33  it('can delete cached items', async () => {34    const value = await cache.resolve('hello', 'world');35    expect(value).to.be('world');36    await cache.del('hello');37    const nextValue = await cache.resolve('hello');38    expect(nextValue).to.be(undefined);39  });40  it('can delete multiple cached items using wildcard *', async () => {41    const projectName = await cache.resolve('project.name', 'TheProject');42    const projectSettingsFile = await cache.resolve('project.file.settings', 'SettingsFile');43    expect(projectName).to.be('TheProject');44    expect(projectSettingsFile).to.be('SettingsFile');45    await cache.del('project.', true);46    const nextProjectName = await cache.resolve('project.name');47    const nextProjectSettingsFile = await cache.resolve('project.file.settings');48    expect(nextProjectName).to.be(undefined);49    expect(nextProjectSettingsFile).to.be(undefined);50  });51  it('can clear the cache', async () => {52    await cache.resolve('hello', 'world');53    await cache.resolve('goodbye', 'mars');54    const value = await cache.resolve('hello');55    const value2 = await cache.resolve('goodbye');56    expect(value).to.be('world');57    expect(value2).to.be('mars');58    cache.clear();59    const newValue = await cache.resolve('hello');60    const newValue2 = await cache.resolve('goodbye');61    expect(newValue).to.be(undefined);62    expect(newValue2).to.be(undefined);63  });64  it('can use custom storage', async () => {65    const customStorage = new InMemoryStorage();66    const customCache = createCache({ customStorage });67    let value;68    await customCache.resolve('hello', 'world');69    value = await customCache.resolve('hello');70    expect(value).to.be('world');71    value = await cache.resolve('hello', 'world');72    expect(value).to.be('world');73    await cache.del('hello');74    const nextValue = await cache.resolve('hello');75    expect(nextValue).to.be(undefined);76    customCache.teardown();77  });78  after(() => cache.teardown());...

Full Screen

Full Screen

Home.js

Source:Home.js Github

copy

Full Screen

1import React from 'react';2const style = {3    marginLeft:"80px",marginTop:"30px",marginRight:"60px",marginDown:"30px"4}5const styleText ={6    marginLeft:"150px"7}8export default function Home(){9    return(10       11        <div className='Book' style={{background:"#fff0e6",tabSize:"400px"}} >12             13     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1" ></img>14     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>15     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>16     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>17     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>18     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>19     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>20     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>21     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>22     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>23     <img style={style} src="https://woblink.com/media/cache/resolve/web_view_small/products/images/6243a1a51c19a.jpeg" alt="Ksiazka 1"></img>24              </div>25             26        27       28      29    )30    function renderUserTable()31  {32    return(33      <div className='table-reponsive mt-5'>34        <table className='table table-bordered border-dark'>35          <thead>36            <tr>37            <th scope='col'>EventId</th>38              <th scope='col'>Name</th>39              <th scope='col'>Password</th>40              </tr>41              </thead>42              43              <tbody>44              45              </tbody>46              </table>47              48              </div>49    )50  }...

Full Screen

Full Screen

packer-cache-spec.js

Source:packer-cache-spec.js Github

copy

Full Screen

1'use strict';2describe('RMPackerCache', function() {3  var restmod, packerCache, Bike, Part;4  beforeEach(module('restmod'));5  beforeEach(inject(function($injector) {6    restmod = $injector.get('restmod');7    packerCache = $injector.get('RMPackerCache');8    Bike = restmod.model('/api/bikes', {9      NAME: 'bike'10    });11    Part = restmod.model('/api/parts', {12      NAME: 'part'13    });14  }));15  describe('restore', function() {16    it('shouldnt fail if packer not initialized', function() {17      expect(function() {18        packerCache.resolve(Bike.$new(1));19      }).not.toThrow();20    });21    describe('given data has been fed', function() {22      beforeEach(function() {23        packerCache.prepare();24        packerCache.feed('bikes', [ { id: 1, model: 'Meta' }, { id: 2, model: 'Slash' } ]);25      });26      it('should feed data if record id is found', function() {27        var bike = packerCache.resolve(Bike.$new(1));28        expect(bike.model).toEqual('Meta');29      });30      it('shouldnt feed data if record is not found', function() {31        var bike = packerCache.resolve(Bike.$new(4));32        expect(bike.model).toBeUndefined();33      });34      it('shouldnt feed data if record is not found', function() {35        var bike = packerCache.resolve(Bike.$new(4));36        expect(bike.model).toBeUndefined();37      });38      it('shouldnt fail if record type is not cached', function() {39        expect(function() {40          var part = packerCache.resolve(Part.$new(1));41          expect(part.model).toBeUndefined();42        }).not.toThrow();43      });44    });45  });...

Full Screen

Full Screen

cache.js

Source:cache.js Github

copy

Full Screen

1import LRU from 'lru-cache'2export function cacheFactory (options) {3  const finalOptions = Object.assign({}, {4    max: 100,5    maxAge: 1000 * 60 * 60,6    key: 'id',7    refresh: null,8    resolveKey: null,9  }, options)10  const cache = {11    lru: LRU({12      max: finalOptions.max,13      maxAge: finalOptions.maxAge,14    }),15    async set (item, ...args) {16      let key17      if (args && cache.resolveKey) {18        key = await cache.resolveKey(...args)19      } else {20        key = item[cache.key]21      }22      cache.lru.set(key, item)23    },24    async put (items, mapKeyArgs = null) {25      for (const item of items) {26        if (mapKeyArgs) {27          const args = await mapKeyArgs(item)28          await cache.setOne(item, ...args)29        } else {30          await cache.setOne(item)31        }32      }33    },34    async get (...args) {35      let key36      if (cache.resolveKey) {37        key = await cache.resolveKey(...args)38      } else {39        key = args[0]40      }41      let item = cache.lru.get(key)42      // Refresh43      if (!item && cache.refresh) {44        const refreshArgs = cache.resolveKey ? args : key45        item = await cache.refresh(...refreshArgs)46        cache.set(item, ...args)47      }48      return item49    },50    ...finalOptions,51  }52  return cache...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add("resolve", (path) => {2  return cy.window().then((win) => {3    return win.Cypress._.get(win, path);4  });5});6Cypress.Commands.add("resolve", (path) => {7  return cy.window().then((win) => {8    return win.Cypress._.get(win, path);9  });10});11Cypress.Commands.add("resolve", (path) => {12  return cy.window().then((win) => {13    return win.Cypress._.get(win, path);14  });15});16Cypress.Commands.add("resolve", (path) => {17  return cy.window().then((win) => {18    return win.Cypress._.get(win, path);19  });20});21Cypress.Commands.add("resolve", (path) => {22  return cy.window().then((win) => {23    return win.Cypress._.get(win, path);24  });25});26Cypress.Commands.add("resolve", (path) => {27  return cy.window().then((win) => {28    return win.Cypress._.get(win, path);29  });30});31Cypress.Commands.add("resolve", (path) => {32  return cy.window().then((win) => {33    return win.Cypress._.get(win, path);34  });35});36Cypress.Commands.add("resolve", (path) => {37  return cy.window().then((win) => {38    return win.Cypress._.get(win, path);39  });40});41Cypress.Commands.add("resolve", (path) => {42  return cy.window().then((win) => {43    return win.Cypress._.get(win, path);44  });45});46Cypress.Commands.add("resolve", (path) => {47  return cy.window().then((win) => {48    return win.Cypress._.get(win, path);49  });50});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2  it('test', () => {3    cy.visit(Cypress.config().baseUrl)4    cy.get('a').click()5    cy.url().should('include', '/test')6  })7})8{9}10import './commands'11Cypress.Commands.add('visit', (url, options) => {12  if (url.indexOf('http') !== 0) {13    url = Cypress.config().baseUrl + url14  }15  cy.visit(url, options)16})17cy.location().then((loc) => {18  console.log(loc.href);19});20cy.location().then((loc) => {21  console.log(loc.href);22});23I’ve tried using cy.intercept() to intercept the requests and cy.route() to stub the responses. Neither of these approaches work. I can see

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2  it('test', () => {3    cy.get('.action-upload').attachFile('example.json', { subjectType: 'drag-n-drop' });4    cy.get('.action-upload').attachFile('example.json', { subjectType: 'input' });5  });6});7import 'cypress-file-upload';8const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');9const { initPlugin } = require('cypress-plugin-snapshots/plugin');10const { addMatchImageSnapshotPlugin: addMatchImageSnapshotPlugin2 } = require('cypress-image-snapshot/plugin');11module.exports = (on, config) => {12  addMatchImageSnapshotPlugin(on, config);13  initPlugin(on, config);14  addMatchImageSnapshotPlugin2(on, config);15};16import 'cypress-plugin-snapshots/commands';17import 'cypress-image-snapshot/command';18import 'cypress-file-upload';

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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