我想在 karma 中编写测试 a 来检查默认状态。如何为 UI-Router 设置错误的 URL?
JS文件:
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'home.html'
});
});
测试:
describe('UI-Route configuration', function() {
beforeEach(module('App'));
it('should load the home page.', inject(function($state) {
var state = $state.get('home');
assert.isDefined(state.templateUrl);
expect(state.templateUrl).to.equal('home.html');
}));
it('should load the home page when other path', inject(function($state) {
//something to write here, setting wrong url
}));
})
请帮我。