test(router): use Object.isFrozen instead of relying on an exception

This commit is contained in:
Marc Laval 2016-08-09 16:20:26 +02:00 committed by Alex Rickabaugh
parent 4728f29f67
commit 8be6b12c2b
1 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@ describe('recognize', () => {
checkRecognize([{path: 'a/:id', component: ComponentA}], 'a/10', (s: RouterStateSnapshot) => { checkRecognize([{path: 'a/:id', component: ComponentA}], 'a/10', (s: RouterStateSnapshot) => {
checkActivatedRoute(s.root, '', {}, RootComponent); checkActivatedRoute(s.root, '', {}, RootComponent);
const child = s.firstChild(s.root); const child = s.firstChild(s.root);
expect(() => child.params['prop'] = 'new').toThrowError(/Can't add property/); expect(Object.isFrozen(child.params)).toBeTruthy();
}); });
}); });
@ -637,7 +637,7 @@ describe('recognize', () => {
it('should freeze query params object', () => { it('should freeze query params object', () => {
checkRecognize([{path: 'a', component: ComponentA}], 'a?q=11', (s: RouterStateSnapshot) => { checkRecognize([{path: 'a', component: ComponentA}], 'a?q=11', (s: RouterStateSnapshot) => {
expect(() => s.queryParams['prop'] = 'new').toThrowError(/Can't add property/); expect(Object.isFrozen(s.queryParams)).toBeTruthy();
}); });
}); });
}); });