[英]Unit Testing Query Params for ui-router
這篇文章解釋了如何測試特定的:id
ui-router:
it('should respond to URL', function() {
expect($state.href('state', { id: 1 })).toEqual('#/state/1');
});
如何為單元測試傳遞查詢參數?
例:
$stateProvider:
$state("foo") {
url: "/foo?myParam1
如何使用myParam1=bar
的傳入查詢參數測試foo
狀態?
it('should respond to URL with params', function() {
expect($state.href('foo', { myParam1: 'bar' })).toEqual('#/foo?myParam1=bar');
});
然后你的路線看起來像
$stateProvider
.state("foo") {
url: "/foo?:myParam1"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.