我正在尝试测试从以下状态的onEnter调用的Angular UI Bootstrap模式:
.state("profile.index.edit.services", {
url: "/edit/services/:serviceCode",
parent:"profile.index",
onEnter: ['$stateParams', '$state', '$modal',function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'profile/edit-services-modal.html',
controller: 'ProfileEditServicesController',
resolve: {
profileData: function(CacheService){
return CacheService.getItem(CacheService.Items.Profile.loadedProfile);
},
allServicesList: function(ProfileService){
return ProfileService.getAllServicesList($stateParams.serviceCode,$stateParams.orgId);
},
serviceCode: function() {
return $stateParams.serviceCode;
}
}
}).result.then(function(result) {
if (result) {
return $state.transitionTo("profile.index", { orgId: $stateParams.orgId });
}
else { // cancel
return $state.transitionTo("profile.index", { orgId: $stateParams.orgId }); // don't reload
}
}, function () {
// executes on close/cancel/ESC
return $state.transitionTo("profile.index", { orgId: $stateParams.orgId });
});
}]
})
我一直在努力争先恐后地尝试许多不同的事情来设置测试,但似乎无法弄明白。任何掠夺者或建议都非常感谢!!!!
顺便说一句,上面的状态是这些状态的后代,我已经能够为该传递编写测试:
.state('profile.index', {
url: '/:orgId',
views: {
'profile-index@profile': {
templateUrl: 'profile/view-profile.html',
controller: 'ProfileController'
},
'header@': {
templateUrl: 'common/layout/header.html',
controller: 'HeaderController'
},
'footer@':{
templateUrl: 'common/layout/footer.html',
controller: 'FooterController'
}
},
resolve: {
profileData: function(ProfileService, $stateParams){
return ProfileService.getProfile($stateParams.orgId, true);
}
}
})
.state('profile.index.edit', {
url: '',
abstract: true
})
答案 0 :(得分:1)