【发布时间】:2015-05-19 12:24:51
【问题描述】:
我有一个这样的配置:
angular.module('myModule', ['ui.router'])
.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('app.home', {
abstract: true,
url: '/home',
template: '<div>Foo Bar</div>'
});
}]);
还有一个像这样使用 jasmine 的单元测试:
'use strict';
describe('Module: myModule', function() {
var $rootScope, $state;
beforeEach(module('ui.router'));
beforeEach(module('myModule'));
beforeEach(inject(function(_$rootScope_, _$state_) {
$state = _$state_;
$rootScope = _$rootScope_;
}));
it('must have a route state for home', function(){
console.log($state.get('app.home')); // this returns null
});
});
但是我无法让配置中的状态显示在$state.get()返回的数组中
我还检查了包含配置的文件已加载并且它就在那里。 谁能说我做错了什么?基本上我只是想测试我期望的状态是否存在于“myModule”的配置中
【问题讨论】:
标签: javascript angularjs unit-testing angular-ui-router