angularjs - Testing angular ui-router state urls -
trying write basic tests ui-router , running issues. have referred angular ui router unit testing (states urls) , related blog post http://bardo.io/posts/testing-your-ui-router-configuration/, cannot simpler version of explained there working. below code implementing state test. works correctly in browser.
# routes.coffee angular.module('waffle', ['ui.router']).config([ '$stateprovider' ($stateprovider) -> $stateprovider.state 'app.board.settings.edit-github-enterprise-source', url: '/sources/:source/edit' templateurl: "/settings/sources/edit/github.html" controller: "settingseditsourcecontroller controller" ])
the associated test file karma/mocha:
# routes-spec.coffee describe 'routes', -> describe 'app.board.settings.edit-github-source', -> beforeeach module 'waffle' beforeeach inject (@$state, $templatecache) -> $templatecache.put '/settings/sources/edit/github.html', '' 'should respond url', -> console.log @$state.get 'app.board.settings.edit-github-source' # log: null console.log @$state.includes 'app.board.settings.edit-github-source' # log: undefined @$state.href 'app.board.settings.edit-github-source', source: '1234' .should.equal '/sources/1234/edit'
the test fails saying cannot read property 'should' of null
.
thanks help in advance.
angularjs unit-testing coffeescript angular-ui-router
No comments:
Post a Comment