test(ngcc): avoid using spy in `Esm2015ReflectionHost` test (#33878)
A testcase that was using a spy has shown itself to be brittle, and its assertions can easily be moved into a related test. PR Close #33878
This commit is contained in:
parent
e2cba6ed7d
commit
19a6c158d2
|
@ -379,28 +379,12 @@ runInEachFileSystem(() => {
|
||||||
'TemplateRef',
|
'TemplateRef',
|
||||||
null,
|
null,
|
||||||
]);
|
]);
|
||||||
});
|
|
||||||
|
|
||||||
describe('(returned parameters `decorators`)', () => {
|
|
||||||
it('should use `getImportOfIdentifier()` to retrieve import info', () => {
|
|
||||||
const mockImportInfo = {} as Import;
|
|
||||||
const spy = spyOn(Esm2015ReflectionHost.prototype, 'getImportOfIdentifier')
|
|
||||||
.and.returnValue(mockImportInfo);
|
|
||||||
|
|
||||||
const {program} = makeTestBundleProgram(_('/some_directive.js'));
|
|
||||||
const host =
|
|
||||||
new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
|
|
||||||
const classNode = getDeclaration(
|
|
||||||
program, _('/some_directive.js'), 'SomeDirective', isNamedVariableDeclaration);
|
|
||||||
const parameters = host.getConstructorParameters(classNode);
|
|
||||||
const decorators = parameters ![2].decorators !;
|
const decorators = parameters ![2].decorators !;
|
||||||
|
|
||||||
expect(decorators.length).toEqual(1);
|
expect(decorators.length).toEqual(1);
|
||||||
expect(decorators[0].import).toBe(mockImportInfo);
|
expect(decorators[0].name).toBe('Inject');
|
||||||
|
expect(decorators[0].import !.from).toBe('@angular/core');
|
||||||
const typeIdentifier = spy.calls.mostRecent().args[0] as ts.Identifier;
|
expect(decorators[0].import !.name).toBe('Inject');
|
||||||
expect(typeIdentifier.text).toBe('Inject');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue