javascript - How to unit test onEnter and resolve of ui-router state -
I am trying to test an angular UI bootstrap model which is being said to the inverter of the following situation: / P>
.state ("profile.index.edit.services", {url: "/ edit / services /: serviceCode", parent: "profile.index", onEnter: [' $ StateParams', '$ state', '$ modal', function ($ stateParams, $ state, $ modal) {$ modal.open ({templateUrl: 'profile / editing services- modal.html', administrator: 'ProfileEditServicesController' Solved to: {profileData: Function (CacheService) {return CacheService.getItem (CacheService.Items.Profile.loadedPr) Ofile);}, allServicesList: Function (ProfileService) {Return ProfileService.getAllServicesList ($ stateParams.serviceCode, $ stateParams.orgId);}, serviceCode: function () {return $ state mercury.ServiceCode;}}}} {Work (results) {if (consequence) {return $ state.transitionTo ("profile.index", {orgId: $ stateParams.orgId})}} other {// cancellation $ status.transitionTo ("profile.index ", {OrgId: $ stateParams.orgId}); // is not reloaded}}, function () {// execute / cancel / ESC return at $ state.transitionTo ("profile index," {orgId: $ stateParams.orgId});}; }]}} I'm leading my way against many different things to try this test, but I can not understand it.
By the way, the above state is a descendant of these states, which I am capable of writing a test for that:
.state ('profile.index', {url : '/: OrgId', idea: {'profile-index @ profile': {templateUrl: 'profile / view-profile.html', Controller: ProfileController '},' Title @ ': {templateUrl:' common / layout / Header.html ', Controller:' HeaderController '},' Footer @ ': {templateUrl:' mango / layout / footer.html ', controller:' footerController '}}, solve: {profileData: function (ProfileService, $ stateParams) {Return ProfileService.getProfile ($ stateParams.orgId, true);}}}) .state ('profile.index.edit', {url: '', abstract: true})
Have you ever figured out this? You should have passed a designated controller, the way you can test that controller (because it is just a function) instead of leaving it directly on the inverter
Comments
Post a Comment