我需要测试我通过angularJs重定向的url路径
$state.go('myPage');
我试图在摩卡柴中获得状态
it('should load the page.', inject(function ($state) {
var state = $state.get('myPage');
但我收到错误“无法解决'myPage'状态''”
更多细节
控制器
var pageRedirection = function () {
var absUrl = $location.absUrl(),
url = absUrl.split('/'),
length = url.length,
pageURL = url[length-2],
state;
state = SELECT_LINE_CONST.SELECT_RATE_PLAN_STATE;
$state.go(state+channel);};
配置文件
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider.state('myPage', {
url: '/myPageData/WEB',
templateUrl: function () {
return 'scripts/html/views/myPage.html';
},
controller: 'myPageCtrl',
css: 'styles/lazy-load/myPage.css'
});
$urlRouterProvider.otherwise('/');})
.constant('SELECT_LINE_CONST', {
'SELECT_RATE_PLAN_STATE': 'myPage'
});
摩卡柴it('Testing buttonClick function if url === myPage', function() {
var state = 'myPage';
var objState = $state.go(state);
$rootScope.$digest();
selectLineService.pageRedirection();
expect(selectLineService.pageRedirection()).to.be.ok;
});
任何想法如何解决它..