javascript - Setting up and testing UI Router -


i'm trying use ncy-angular-breadcrumb, uses ui routes. have module set house ui routes:

(function () {     var app = angular.module('configurator.uiroutes', ['ui.router', 'ncy-angular-breadcrumb']);      app.config(['$stateprovider', function ($stateprovider) {         $stateprovider             .state('home', {                 url: '/',                 ncybreadcrumb: {                     label: 'series'                 }             });     }]);  })(); 

i have test see if route works:

describe('configurator ui routes', function () {      beforeeach(module('configurator.uiroutes'));     beforeeach(module('ui.router'));      var $state, $rootscope, state = '/';      // inject , assign $state , $rootscope services.     beforeeach(inject(function (_$state_, _$rootscope_) {         $state = _$state_;         $rootscope = _$rootscope_;     }));      //test whether url correct     it('should activate state', function () {         $state.go(state);         $rootscope.$digest();         expect($state.current.name).tobe('home');     }); }); 

which produces error:

error: not resolve '/' state '' 

i'm not getting ui router , either how works, or it's supposed do. want grab parts of url , pass info ncybreadcrumb, can't base url work.

any pointers or awesome!

edit: i've gotten test pass replacing '/' 'home' in test. bigger question is: there way test when url '/' hit, state.current.name becomes 'home'. in use of app, doesn't appear happening, , i'm hoping unit test can tell me why.

this single page application, if that's relevant.

error enough self explanatory, asked ui-router redirect on / state using $state.go

basically $state.go asks state name rather url.

var $state, $rootscope, state = 'home'; //<--changed `/` `home` 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -