fix(testing): remove the `toThrowErrorWith` matcher (jasmine has `toThrowError`)
BREAKING CHANGE: Before: expect(...).toThrowErrorWith(msg); After: expect(...).toThrowError(msg);
This commit is contained in:
parent
6420f75320
commit
e1e5c40ef7
|
@ -141,16 +141,14 @@ export function main() {
|
|||
var dir = new NgControlName(form, null, null, [defaultAccessor]);
|
||||
dir.name = 'invalidName';
|
||||
|
||||
expect(() => form.addControl(dir))
|
||||
.toThrowError(new RegExp('Cannot find control \'invalidName\''));
|
||||
expect(() => form.addControl(dir)).toThrowError(/Cannot find control 'invalidName'/);
|
||||
});
|
||||
|
||||
it('should throw when no value accessor', () => {
|
||||
var dir = new NgControlName(form, null, null, null);
|
||||
dir.name = 'login';
|
||||
|
||||
expect(() => form.addControl(dir))
|
||||
.toThrowError(new RegExp('No value accessor for \'login\''));
|
||||
expect(() => form.addControl(dir)).toThrowError(/No value accessor for 'login'/);
|
||||
});
|
||||
|
||||
it('should set up validators', fakeAsync(() => {
|
||||
|
|
|
@ -47,7 +47,7 @@ export function main() {
|
|||
|
||||
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((fixture) => {
|
||||
expect(() => fixture.detectChanges())
|
||||
.toThrowError(new RegExp(`ngFormModel expects a form. Please pass one in.`));
|
||||
.toThrowError(/ngFormModel expects a form\. Please pass one in/);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AST, BindingPipe, LiteralPrimitive} from '@angular/compiler/src/expression_parser/ast';
|
||||
import {AST, BindingPipe} from '@angular/compiler/src/expression_parser/ast';
|
||||
import {Lexer} from '@angular/compiler/src/expression_parser/lexer';
|
||||
import {Parser} from '@angular/compiler/src/expression_parser/parser';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
|
||||
|
@ -10,26 +10,23 @@ import {Unparser} from './unparser';
|
|||
export function main() {
|
||||
function createParser() { return new Parser(new Lexer()); }
|
||||
|
||||
function parseAction(text: any /** TODO #9100 */, location: any /** TODO #9100 */ = null): any {
|
||||
function parseAction(text: string, location: any = null): any {
|
||||
return createParser().parseAction(text, location);
|
||||
}
|
||||
|
||||
function parseBinding(text: any /** TODO #9100 */, location: any /** TODO #9100 */ = null): any {
|
||||
function parseBinding(text: string, location: any = null): any {
|
||||
return createParser().parseBinding(text, location);
|
||||
}
|
||||
|
||||
function parseTemplateBindings(
|
||||
text: any /** TODO #9100 */, location: any /** TODO #9100 */ = null): any {
|
||||
function parseTemplateBindings(text: string, location: any = null): any {
|
||||
return createParser().parseTemplateBindings(text, location).templateBindings;
|
||||
}
|
||||
|
||||
function parseInterpolation(
|
||||
text: any /** TODO #9100 */, location: any /** TODO #9100 */ = null): any {
|
||||
function parseInterpolation(text: string, location: any = null): any {
|
||||
return createParser().parseInterpolation(text, location);
|
||||
}
|
||||
|
||||
function parseSimpleBinding(
|
||||
text: any /** TODO #9100 */, location: any /** TODO #9100 */ = null): any {
|
||||
function parseSimpleBinding(text: string, location: any = null): any {
|
||||
return createParser().parseSimpleBinding(text, location);
|
||||
}
|
||||
|
||||
|
@ -135,10 +132,8 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should only allow identifier, string, or keyword as map key', () => {
|
||||
expectActionError('{(:0}').toThrowError(
|
||||
new RegExp('expected identifier, keyword, or string'));
|
||||
expectActionError('{1234:0}')
|
||||
.toThrowError(new RegExp('expected identifier, keyword, or string'));
|
||||
expectActionError('{(:0}').toThrowError(/expected identifier, keyword, or string/);
|
||||
expectActionError('{1234:0}').toThrowError(/expected identifier, keyword, or string/);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -149,9 +144,9 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should only allow identifier or keyword as member names', () => {
|
||||
expectActionError('x.(').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectActionError('x. 1234').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectActionError('x."foo"').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectActionError('x.(').toThrowError(/identifier or keyword/);
|
||||
expectActionError('x. 1234').toThrowError(/identifier or keyword/);
|
||||
expectActionError('x."foo"').toThrowError(/identifier or keyword/);
|
||||
});
|
||||
|
||||
it('should parse safe field access', () => {
|
||||
|
@ -180,8 +175,8 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should throw on incorrect ternary operator syntax', () => {
|
||||
expectActionError('true?1').toThrowError(new RegExp(
|
||||
'Parser Error: Conditional expression true\\?1 requires all 3 expressions'));
|
||||
expectActionError('true?1').toThrowError(
|
||||
/Parser Error: Conditional expression true\?1 requires all 3 expressions/);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -193,15 +188,14 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should throw on safe field assignments', () => {
|
||||
expectActionError('a?.a = 123')
|
||||
.toThrowError(new RegExp('cannot be used in the assignment'));
|
||||
expectActionError('a?.a = 123').toThrowError(/cannot be used in the assignment/);
|
||||
});
|
||||
|
||||
it('should support array updates', () => { checkAction('a[0] = 200'); });
|
||||
});
|
||||
|
||||
it('should error when using pipes',
|
||||
() => { expectActionError('x|blah').toThrowError(new RegExp('Cannot have a pipe')); });
|
||||
() => { expectActionError('x|blah').toThrowError(/Cannot have a pipe/); });
|
||||
|
||||
it('should store the source in the result',
|
||||
() => { expect(parseAction('someExpr').source).toBe('someExpr'); });
|
||||
|
@ -210,24 +204,22 @@ export function main() {
|
|||
() => { expect(parseAction('someExpr', 'location').location).toBe('location'); });
|
||||
|
||||
it('should throw when encountering interpolation', () => {
|
||||
expectActionError('{{a()}}').toThrowErrorWith(
|
||||
'Got interpolation ({{}}) where expression was expected');
|
||||
expectActionError('{{a()}}').toThrowError(
|
||||
/Got interpolation \(\{\{\}\}\) where expression was expected/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('general error handling', () => {
|
||||
it('should throw on an unexpected token', () => {
|
||||
expectActionError('[1,2] trac').toThrowError(new RegExp('Unexpected token \'trac\''));
|
||||
});
|
||||
it('should throw on an unexpected token',
|
||||
() => { expectActionError('[1,2] trac').toThrowError(/Unexpected token \'trac\'/); });
|
||||
|
||||
it('should throw a reasonable error for unconsumed tokens', () => {
|
||||
expectActionError(')').toThrowError(
|
||||
new RegExp('Unexpected token \\) at column 1 in \\[\\)\\]'));
|
||||
expectActionError(')').toThrowError(/Unexpected token \) at column 1 in \[\)\]/);
|
||||
});
|
||||
|
||||
it('should throw on missing expected token', () => {
|
||||
expectActionError('a(b').toThrowError(
|
||||
new RegExp('Missing expected \\) at the end of the expression \\[a\\(b\\]'));
|
||||
/Missing expected \) at the end of the expression \[a\(b\]/);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -246,9 +238,9 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should only allow identifier or keyword as formatter names', () => {
|
||||
expectBindingError('"Foo"|(').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectBindingError('"Foo"|1234').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectBindingError('"Foo"|"uppercase"').toThrowError(new RegExp('identifier or keyword'));
|
||||
expectBindingError('"Foo"|(').toThrowError(/identifier or keyword/);
|
||||
expectBindingError('"Foo"|1234').toThrowError(/identifier or keyword/);
|
||||
expectBindingError('"Foo"|"uppercase"').toThrowError(/identifier or keyword/);
|
||||
});
|
||||
|
||||
it('should parse quoted expressions', () => { checkBinding('a:b', 'a:b'); });
|
||||
|
@ -270,17 +262,15 @@ export function main() {
|
|||
it('should store the passed-in location',
|
||||
() => { expect(parseBinding('someExpr', 'location').location).toBe('location'); });
|
||||
|
||||
it('should throw on chain expressions', () => {
|
||||
expect(() => parseBinding('1;2')).toThrowError(new RegExp('contain chained expression'));
|
||||
});
|
||||
it('should throw on chain expressions',
|
||||
() => { expect(() => parseBinding('1;2')).toThrowError(/contain chained expression/); });
|
||||
|
||||
it('should throw on assignment', () => {
|
||||
expect(() => parseBinding('a=2')).toThrowError(new RegExp('contain assignments'));
|
||||
});
|
||||
it('should throw on assignment',
|
||||
() => { expect(() => parseBinding('a=2')).toThrowError(/contain assignments/); });
|
||||
|
||||
it('should throw when encountering interpolation', () => {
|
||||
expectBindingError('{{a.b}}').toThrowErrorWith(
|
||||
'Got interpolation ({{}}) where expression was expected');
|
||||
expectBindingError('{{a.b}}').toThrowError(
|
||||
/Got interpolation \(\{\{\}\}\) where expression was expected/);
|
||||
});
|
||||
|
||||
it('should parse conditional expression', () => { checkBinding('a < b ? a : b'); });
|
||||
|
@ -335,11 +325,11 @@ export function main() {
|
|||
|
||||
expect(() => {
|
||||
parseTemplateBindings('(:0');
|
||||
}).toThrowError(new RegExp('expected identifier, keyword, or string'));
|
||||
}).toThrowError(/expected identifier, keyword, or string/);
|
||||
|
||||
expect(() => {
|
||||
parseTemplateBindings('1234:0');
|
||||
}).toThrowError(new RegExp('expected identifier, keyword, or string'));
|
||||
}).toThrowError(/expected identifier, keyword, or string/);
|
||||
});
|
||||
|
||||
it('should detect expressions as value', () => {
|
||||
|
@ -452,12 +442,12 @@ export function main() {
|
|||
|
||||
it('should throw on empty interpolation expressions', () => {
|
||||
expect(() => parseInterpolation('{{}}'))
|
||||
.toThrowErrorWith(
|
||||
'Parser Error: Blank expressions are not allowed in interpolated strings');
|
||||
.toThrowError(
|
||||
/Parser Error: Blank expressions are not allowed in interpolated strings/);
|
||||
|
||||
expect(() => parseInterpolation('foo {{ }}'))
|
||||
.toThrowErrorWith(
|
||||
'Parser Error: Blank expressions are not allowed in interpolated strings');
|
||||
.toThrowError(
|
||||
/Parser Error: Blank expressions are not allowed in interpolated strings/);
|
||||
});
|
||||
|
||||
it('should parse conditional expression',
|
||||
|
@ -514,13 +504,12 @@ export function main() {
|
|||
|
||||
it('should throw when the given expression is not just a field name', () => {
|
||||
expect(() => parseSimpleBinding('name + 1'))
|
||||
.toThrowErrorWith(
|
||||
'Host binding expression can only contain field access and constants');
|
||||
.toThrowError(/Host binding expression can only contain field access and constants/);
|
||||
});
|
||||
|
||||
it('should throw when encountering interpolation', () => {
|
||||
expect(() => parseSimpleBinding('{{exp}}'))
|
||||
.toThrowErrorWith('Got interpolation ({{}}) where expression was expected');
|
||||
.toThrowError(/Got interpolation \(\{\{\}\}\) where expression was expected/);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -711,8 +711,8 @@ export function main() {
|
|||
it('should report missing @Self() deps as errors', () => {
|
||||
var dirA = createDir('[dirA]', {deps: ['self:provider0']});
|
||||
expect(() => parse('<div dirA></div>', [dirA]))
|
||||
.toThrowErrorWith(
|
||||
'No provider for provider0 ("[ERROR ->]<div dirA></div>"): TestComp@0:0');
|
||||
.toThrowError(
|
||||
'Template parse errors:\nNo provider for provider0 ("[ERROR ->]<div dirA></div>"): TestComp@0:0');
|
||||
});
|
||||
|
||||
it('should change missing @Self() that are optional to nulls', () => {
|
||||
|
@ -725,8 +725,8 @@ export function main() {
|
|||
it('should report missing @Host() deps as errors', () => {
|
||||
var dirA = createDir('[dirA]', {deps: ['host:provider0']});
|
||||
expect(() => parse('<div dirA></div>', [dirA]))
|
||||
.toThrowErrorWith(
|
||||
'No provider for provider0 ("[ERROR ->]<div dirA></div>"): TestComp@0:0');
|
||||
.toThrowError(
|
||||
'Template parse errors:\nNo provider for provider0 ("[ERROR ->]<div dirA></div>"): TestComp@0:0');
|
||||
});
|
||||
|
||||
it('should change missing @Host() that are optional to nulls', () => {
|
||||
|
@ -1171,7 +1171,7 @@ Can't bind to 'invalidProp' since it isn't a known native property ("<div [ERROR
|
|||
});
|
||||
|
||||
it('should report errors in expressions', () => {
|
||||
expect(() => parse('<div [prop]="a b"></div>', [])).toThrowErrorWith(`Template parse errors:
|
||||
expect(() => parse('<div [prop]="a b"></div>', [])).toThrowError(`Template parse errors:
|
||||
Parser Error: Unexpected token 'b' at column 3 in [a b] in TestComp@0:5 ("<div [ERROR ->][prop]="a b"></div>"): TestComp@0:5`);
|
||||
});
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ export function main() {
|
|||
|
||||
it('should throw when Component has neither template nor templateUrl set', () => {
|
||||
expect(() => resolver.resolve(ComponentWithoutView))
|
||||
.toThrowErrorWith(
|
||||
'Component \'ComponentWithoutView\' must have either \'template\' or \'templateUrl\' set');
|
||||
.toThrowError(
|
||||
/Component 'ComponentWithoutView' must have either 'template' or 'templateUrl' set/);
|
||||
});
|
||||
|
||||
it('should throw when simple class has no component decorator', () => {
|
||||
expect(() => resolver.resolve(SimpleClass))
|
||||
.toThrowErrorWith('Could not compile \'SimpleClass\' because it is not a component.');
|
||||
.toThrowError('Could not compile \'SimpleClass\' because it is not a component.');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should throw when given an invalid collection', () => {
|
||||
expect(() => differ.diff('invalid')).toThrowErrorWith('Error trying to diff \'invalid\'');
|
||||
expect(() => differ.diff('invalid')).toThrowError('Error trying to diff \'invalid\'');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -203,8 +203,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should throw when given an invalid collection', () => {
|
||||
expect(() => differ.diff('invalid'))
|
||||
.toThrowErrorWith('Error trying to diff \'invalid\'');
|
||||
expect(() => differ.diff('invalid')).toThrowError('Error trying to diff \'invalid\'');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export function main() {
|
|||
it('should throw when no suitable implementation found', () => {
|
||||
var differs = new IterableDiffers([]);
|
||||
expect(() => differs.find('some object'))
|
||||
.toThrowErrorWith('Cannot find a differ supporting object \'some object\'')
|
||||
.toThrowError(/Cannot find a differ supporting object 'some object'/);
|
||||
});
|
||||
|
||||
it('should return the first suitable implementation', () => {
|
||||
|
@ -46,7 +46,7 @@ export function main() {
|
|||
var injector = ReflectiveInjector.resolveAndCreate([IterableDiffers.extend([])]);
|
||||
|
||||
expect(() => injector.get(IterableDiffers))
|
||||
.toThrowErrorWith('Cannot extend IterableDiffers without a parent injector');
|
||||
.toThrowError(/Cannot extend IterableDiffers without a parent injector/);
|
||||
});
|
||||
|
||||
it('should extend di-inherited diffesr', () => {
|
||||
|
|
|
@ -65,10 +65,10 @@ class CyclicEngine {
|
|||
}
|
||||
|
||||
class NoAnnotations {
|
||||
constructor(secretDependency: any /** TODO #9100 */) {}
|
||||
constructor(secretDependency: any) {}
|
||||
}
|
||||
|
||||
function factoryFn(a: any /** TODO #9100 */) {}
|
||||
function factoryFn(a: any) {}
|
||||
|
||||
export function main() {
|
||||
var dynamicProviders = [
|
||||
|
@ -211,9 +211,8 @@ export function main() {
|
|||
|
||||
it('should support multiProviders', () => {
|
||||
var injector = createInjector([
|
||||
Engine,
|
||||
/* @ts2dart_Provider */ {provide: Car, useClass: SportsCar, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Car, useClass: CarWithOptionalEngine, multi: true}
|
||||
Engine, {provide: Car, useClass: SportsCar, multi: true},
|
||||
{provide: Car, useClass: CarWithOptionalEngine, multi: true}
|
||||
]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
|
@ -223,10 +222,8 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support multiProviders that are created using useExisting', () => {
|
||||
var injector = createInjector([
|
||||
Engine, SportsCar,
|
||||
/* @ts2dart_Provider */ {provide: Car, useExisting: SportsCar, multi: true}
|
||||
]);
|
||||
var injector = createInjector(
|
||||
[Engine, SportsCar, {provide: Car, useExisting: SportsCar, multi: true}]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(1);
|
||||
|
@ -488,8 +485,8 @@ export function main() {
|
|||
|
||||
it('should support multi providers', () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: TurboEngine, multi: true}
|
||||
{provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
{provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
|
@ -500,8 +497,8 @@ export function main() {
|
|||
|
||||
it('should support providers as hash', () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: TurboEngine, multi: true}
|
||||
{provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
{provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
|
@ -510,9 +507,8 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support multi providers with only one provider', () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true}
|
||||
])[0];
|
||||
var provider =
|
||||
ReflectiveInjector.resolve([{provide: Engine, useClass: BrokenEngine, multi: true}])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
expect(provider.multiProvider).toEqual(true);
|
||||
|
@ -521,17 +517,14 @@ export function main() {
|
|||
|
||||
it('should throw when mixing multi providers with regular providers', () => {
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true}, Engine
|
||||
]);
|
||||
}).toThrowErrorWith('Cannot mix multi providers and regular providers');
|
||||
ReflectiveInjector.resolve(
|
||||
[{provide: Engine, useClass: BrokenEngine, multi: true}, Engine]);
|
||||
}).toThrowError(/Cannot mix multi providers and regular providers/);
|
||||
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve([
|
||||
Engine,
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true}
|
||||
]);
|
||||
}).toThrowErrorWith('Cannot mix multi providers and regular providers');
|
||||
ReflectiveInjector.resolve(
|
||||
[Engine, {provide: Engine, useClass: BrokenEngine, multi: true}]);
|
||||
}).toThrowError(/Cannot mix multi providers and regular providers/);
|
||||
});
|
||||
|
||||
it('should resolve forward references', () => {
|
||||
|
@ -570,16 +563,10 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should allow declaring dependencies with flat arrays', () => {
|
||||
var resolved = ReflectiveInjector.resolve([{
|
||||
provide: 'token',
|
||||
useFactory: (e: any /** TODO #9100 */) => e,
|
||||
deps: [new InjectMetadata('dep')]
|
||||
}]);
|
||||
var nestedResolved = ReflectiveInjector.resolve([{
|
||||
provide: 'token',
|
||||
useFactory: (e: any /** TODO #9100 */) => e,
|
||||
deps: [[new InjectMetadata('dep')]]
|
||||
}]);
|
||||
var resolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [new InjectMetadata('dep')]}]);
|
||||
var nestedResolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [[new InjectMetadata('dep')]]}]);
|
||||
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
||||
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
let ci = fixture.debugElement.componentInstance;
|
||||
ci.ctxProp = trusted;
|
||||
expect(() => fixture.detectChanges())
|
||||
.toThrowErrorWith('Required a safe URL, got a Script');
|
||||
.toThrowError(/Required a safe URL, got a Script/);
|
||||
|
||||
async.done();
|
||||
});
|
||||
|
|
|
@ -31,10 +31,6 @@ expect(element).toHaveCssStyle({width: '100px', height: 'auto'});
|
|||
expect(exception).toContainError('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toThrowErrorWith
|
||||
expect(() => { throw 'Failed to load'; }).toThrowErrorWith('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toImplement
|
||||
expect(SomeClass).toImplement(OtherClass);
|
||||
// #enddocregion
|
||||
|
|
|
@ -27,7 +27,7 @@ export function main() {
|
|||
setTemplateCache(null);
|
||||
expect(() => {
|
||||
xhr = new CachedXHR();
|
||||
}).toThrowErrorWith('CachedXHR: Template cache was not found in $templateCache.');
|
||||
}).toThrowError('CachedXHR: Template cache was not found in $templateCache.');
|
||||
});
|
||||
|
||||
it('should resolve the Promise with the cached file content on success',
|
||||
|
|
|
@ -70,24 +70,6 @@ export interface NgMatchers extends jasmine.Matchers {
|
|||
*/
|
||||
toContainError(expected: any): boolean;
|
||||
|
||||
/**
|
||||
* Expect a function to throw an error with the given error text when executed.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* {@example testing/ts/matchers.ts region='toThrowErrorWith'}
|
||||
*/
|
||||
toThrowErrorWith(expectedMessage: any): boolean;
|
||||
|
||||
/**
|
||||
* Expect a string to match the given regular expression.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* {@example testing/ts/matchers.ts region='toMatchPattern'}
|
||||
*/
|
||||
toMatchPattern(expectedMessage: any): boolean;
|
||||
|
||||
/**
|
||||
* Invert the matchers.
|
||||
*/
|
||||
|
@ -233,26 +215,6 @@ _global.beforeEach(function() {
|
|||
};
|
||||
},
|
||||
|
||||
toThrowErrorWith: function() {
|
||||
return {
|
||||
compare: function(actual: any /** TODO #???? */, expectedText: any /** TODO #???? */) {
|
||||
try {
|
||||
actual();
|
||||
return {
|
||||
pass: false,
|
||||
get message() { return 'Was expected to throw, but did not throw'; }
|
||||
};
|
||||
} catch (e) {
|
||||
var errorMessage = e.toString();
|
||||
return {
|
||||
pass: errorMessage.indexOf(expectedText) > -1,
|
||||
get message() { return 'Expected ' + errorMessage + ' to contain ' + expectedText; }
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
toImplement: function() {
|
||||
return {
|
||||
compare: function(
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
|
||||
|
||||
import {Location} from '@angular/common';
|
||||
import {NumberWrapper} from '../../src/facade/lang';
|
||||
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';
|
||||
import {PromiseWrapper} from '../../src/facade/async';
|
||||
import {ListWrapper} from '../../src/facade/collection';
|
||||
|
||||
import {provide, Component} from '@angular/core';
|
||||
|
||||
import {Router, RouteRegistry, RouterLink, RouterOutlet, AsyncRoute, AuxRoute, Route, RouteParams, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from '@angular/router-deprecated';
|
||||
import {Component} from '@angular/core';
|
||||
import {Router, RouteRegistry, RouterLink, AsyncRoute, AuxRoute, Route, RouteParams, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from '@angular/router-deprecated';
|
||||
import {RootRouter} from '@angular/router-deprecated/src/router';
|
||||
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {SpyLocation} from '@angular/common/testing';
|
||||
|
@ -32,7 +28,7 @@ export function main() {
|
|||
|
||||
beforeEach(inject(
|
||||
[TestComponentBuilder, Router, Location],
|
||||
(tcBuilder: any /** TODO #9100 */, rtr: Router, loc: Location) => {
|
||||
(tcBuilder: TestComponentBuilder, rtr: Router, loc: Location) => {
|
||||
tcb = tcBuilder;
|
||||
router = rtr;
|
||||
location = loc;
|
||||
|
@ -138,8 +134,8 @@ export function main() {
|
|||
.then((_) => {
|
||||
var link = ListWrapper.toJSON(['Book', {number: 100}]);
|
||||
expect(() => fixture.detectChanges())
|
||||
.toThrowErrorWith(
|
||||
`Link "${link}" is ambiguous, use "./" or "../" to disambiguate.`);
|
||||
.toThrowError(new RegExp(escapeRegExp(
|
||||
`Link "${link}" is ambiguous, use "./" or "../" to disambiguate.`)));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -262,7 +262,7 @@ export function main() {
|
|||
RootHostCmp, new Route({path: '/first/...', component: DummyParentCmp, name: 'First'}));
|
||||
expect(() => {
|
||||
registry.generate(['First'], []);
|
||||
}).toThrowError('Link "["First"]" does not resolve to a terminal instruction.');
|
||||
}).toThrowError(/Link "\["First"\]" does not resolve to a terminal instruction./);
|
||||
});
|
||||
|
||||
it('should match matrix params on child components and query params on the root component',
|
||||
|
|
|
@ -13,13 +13,12 @@ export function main() {
|
|||
describe('errors', () => {
|
||||
it('should throw on missing selector', () => {
|
||||
expect(() => getComponentInfo(AttributeNameComponent))
|
||||
.toThrowErrorWith(
|
||||
'Only selectors matching element names are supported, got: [attr-name]');
|
||||
.toThrowError('Only selectors matching element names are supported, got: [attr-name]');
|
||||
});
|
||||
|
||||
it('should throw on non element names', () => {
|
||||
expect(() => getComponentInfo(NoAnnotationComponent))
|
||||
.toThrowErrorWith('No Directive annotation found on NoAnnotationComponent');
|
||||
.toThrowError('No Directive annotation found on NoAnnotationComponent');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1632,8 +1632,6 @@ const PLATFORM_BROWSER_TESTING = [
|
|||
'NgMatchers.toHaveCssStyle(expected:any):boolean',
|
||||
'NgMatchers.toHaveText(expected:any):boolean',
|
||||
'NgMatchers.toImplement(expected:any):boolean',
|
||||
'NgMatchers.toMatchPattern(expectedMessage:any):boolean',
|
||||
'NgMatchers.toThrowErrorWith(expectedMessage:any):boolean',
|
||||
'normalizeCSS(css:string):string',
|
||||
'stringifyElement(el:any):string',
|
||||
'var browserDetection:BrowserDetection',
|
||||
|
|
Loading…
Reference in New Issue