我有一个文件app/routes.coffee
'use strict'
webApp.config [
'$stateProvider'
'$urlRouterProvider'
'$locationProvider'
($stateProvider, $urlRouterProvider, $locationProvider) ->
$urlRouterProvider.otherwise '/'
$stateProvider
.state('dashboard', {
url: '/'
views:
appView:
templateUrl: '/templates/app/dashboard.html'
})
.state('repository', {
url: '/repository/:repo_host/:username/:name'
views:
appView:
templateUrl: '/templates/app/repository.html'
})
.state('profile', {
url: '/profile'
views:
appView:
templateUrl: '/templates/app/profile.html'
})
.state('faq', {
url: '/faq'
views:
appView:
templateUrl: '/templates/app/faq.html'
})
... # lots of other states
.state('account.users.statistics', {
url: '/:host/:username'
views:
statisticsView:
templateUrl: '/templates/app/_userStatistics.html'
})
$locationProvider.html5Mode true
]
但是,我的代码覆盖范围很差:
陈述:55.56%(5/9)分支:0%(0/4)功能:50%(1/2)线:100%(5/5)忽略:无
我可以做些什么来改善我的代码覆盖率?
答案 0 :(得分:1)
it('should test routeProvider', function() {
inject(function($route) {
expect($route.routes['/faq'].controller).toBe('faqCtrl');
expect($route.routes['/faq'].templateUrl).toEqual('/templates/app/faq.html');
});
});
你可以这样测试。 我的代码是用angularjs编写的,所以我只使用jasmine框架测试。对不起,我不懂coffescript,