1
解析'app.history'我正在編寫使用$ stateProvider的單元測試(代碼如下代碼及其測試文件所示)。執行此操作時,它會給出錯誤 - 「錯誤:無法解析'app.history'狀態''」。錯誤:無法從狀態'
$stateProvider
.state('app',
{
url: "/app",
templateUrl: "pages/app/index.html",
controller: function($state) {
$state.go('app.history');
}})
.state('app.history',
{ url: "/history",
templateUrl: "pages/app/modules/History/partials/history.html"
})
單元測試代碼 -
describe("Unit tests for config.jst", function() {
var $rootScope, $injector, $state;
beforeEach(module('ui.router'));
beforeEach(inject(function(_$rootScope_, _$state_, _$injector_, $templateCache) {
$rootScope = _$rootScope_;
$injector = _$injector_;
$state = _$state_;
$templateCache.put("pages/app/index.html", "");
$templateCache.put("pages/app/modules/History/partials/history.html", "");
}));
describe("states", function() {
var state = "app.history";
it("verify state configuration", function() {
//var config = $state.get(state);
$state.go(state);
$rootScope.$digest();
//console.log($state);
expect($state.current.name).to.be.equal(state);
});
});
});