摩卡柴测试用例angularjs UI路由 [英] mocha chai test case for angularjs ui-route
本文介绍了摩卡柴测试用例angularjs UI路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要支付通过摩卡柴angularJs配置文件
I need to cover angularJs config file through mocha chai
我试图
it('should load the page.', inject(function ($location, $rootScope, $state, $httpBackend) {
$httpBackend.whenGET('scripts/select-line-module/views/select-line.html').respond('<div/>');
var state = $state.get('selectLine');
$rootScope.$digest();
assert.isDefined(state.templateUrl());
expect(state.templateUrl).toBe('scripts/select-line-module/views/select-line.html');
}));
我能够覆盖templateUrl功能,但测试用例失败
错误:未定义不是一个函数
I am able to cover templateUrl function but test case is failing error : undefined is not a function
我觉得我很接近,但我是缺少在这里?
I feel i am close , but what i am missing here ?
推荐答案
我做到了像
it('should load the page.', inject(function ($state) {
var state = $state.get('selectLine');
assert.isDefined(state.templateUrl());
expect(state.templateUrl()).to.equal('scripts/select-line-module/views/select-line.html');
}));
这对我的作品
这篇关于摩卡柴测试用例angularjs UI路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文