angular.js/test/service/routeParamsSpec.js
2012-02-28 17:46:58 -08:00

20 lines
581 B
JavaScript

'use strict';
describe('$routeParams', function() {
it('should publish the params into a service', function() {
module(function($routeProvider) {
$routeProvider.when('/foo');
$routeProvider.when('/bar/:barId');
});
inject(function($rootScope, $route, $location, $routeParams) {
$location.path('/foo').search('a=b');
$rootScope.$digest();
expect($routeParams).toEqual({a:'b'});
$location.path('/bar/123').search('x=abc');
$rootScope.$digest();
expect($routeParams).toEqual({barId:'123', x:'abc'});
});
});
});