Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// tslint:disable-next-line no-unnecessary-type-assertion
return setup.mockCache.add(thing, thing.map(t => ngMock(t, setup))) as any; // Recursion
}
if (setup.dontMock.includes(thing) || (isModuleWithProviders(thing) && setup.dontMock.includes(thing.ngModule))) {
return thing;
}
let mock: NgMockable;
try {
if (ngModuleResolver.isNgModule(thing) || isModuleWithProviders(thing)) {
mock = mockModule(thing, setup);
} else if (isPipeTransform(thing)) {
mock = MockPipe(thing as Type, setup.mockPipes.get(thing));
} else if (typeof thing === 'function') { // tslint:disable-line strict-type-predicates
mock = MockDeclaration(thing as Type);
if (
setup.withStructuralDirectives.get(thing as Type)
|| (setup.alwaysRenderStructuralDirectives && setup.withStructuralDirectives.get(thing as Type) !== false)
) {
mock.prototype.ngOnInit = () => undefined;
testFramework.spyOn(mock.prototype, 'ngOnInit', function() {
// tslint:disable-next-line: no-empty
try { this.__render(); } catch (e) { }
});
}
fixEmptySelector(thing as Type, mock);
const stubs = setup.mocks.get(thing);
if (stubs) {
mock = class extends (mock as Type) {
constructor() {
super();