New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng-mocks

Package Overview
Dependencies
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-mocks - npm Package Compare versions

Comparing version 9.0.0 to 9.1.0

dist/lib/common/Mock.d.ts

3

dist/index.d.ts

@@ -6,4 +6,5 @@ export * from './lib/common';

export * from './lib/mock-helper';
export * from './lib/mock-render';
export * from './lib/mock-module';
export * from './lib/mock-pipe';
export * from './lib/mock-render';
export * from './lib/mock-service';

@@ -11,5 +11,6 @@ "use strict";

__export(require("./lib/mock-helper"));
__export(require("./lib/mock-render"));
__export(require("./lib/mock-module"));
__export(require("./lib/mock-pipe"));
__export(require("./lib/mock-render"));
__export(require("./lib/mock-service"));
//# sourceMappingURL=index.js.map
export * from './mock-of.decorator';
export * from './Mock';

@@ -7,2 +7,3 @@ "use strict";

__export(require("./mock-of.decorator"));
__export(require("./Mock"));
//# sourceMappingURL=index.js.map
import { Type } from '@angular/core';
export declare const MockOf: (mockClass: Type<any>) => (constructor: Type<any>) => void;
export declare const MockOf: (mockClass: Type<any>, outputs?: string[] | undefined) => (constructor: Type<any>) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockOf = (mockClass) => (constructor) => {
exports.MockOf = (mockClass, outputs) => (constructor) => {
Object.defineProperties(constructor, {
mockOf: { value: mockClass },
name: { value: `MockOf${mockClass.name}` },
nameConstructor: { value: constructor.name },
});
const mockedMethods = [];
for (const method of Object.getOwnPropertyNames(mockClass.prototype || {})) {
const descriptor = Object.getOwnPropertyDescriptor(mockClass.prototype, method);
const isGetterSetter = descriptor && (descriptor.get || descriptor.set);
if (!isGetterSetter && !constructor.prototype[method]) {
mockedMethods.push(method);
}
}
const mockedOutputs = [];
for (const output of outputs || []) {
mockedOutputs.push(output.split(':')[0]);
}
constructor.prototype.__mockedMethods = mockedMethods;
constructor.prototype.__mockedOutputs = mockedOutputs;
};
//# sourceMappingURL=mock-of.decorator.js.map
import { core } from '@angular/compiler';
import { Type } from '@angular/core';
export declare type MockedComponent<T> = T & {
import { Mock } from '../common';
export declare type MockedComponent<T> = T & Mock & {
__hide(contentChildSelector: string): void;

@@ -8,6 +9,4 @@ __render(contentChildSelector: string, $implicit?: any, variables?: {

}): void;
__simulateChange(value: any): void;
__simulateTouch(): void;
};
export declare function MockComponents(...components: Array<Type<any>>): Array<Type<any>>;
export declare function MockComponent<TComponent>(component: Type<TComponent>, metaData?: core.Directive): Type<TComponent>;
export declare function MockComponent<TComponent>(component: Type<TComponent>, metaData?: core.Directive): Type<MockedComponent<TComponent>>;

@@ -14,2 +14,3 @@ "use strict";

const forms_1 = require("@angular/forms");
const tests_1 = require("../../tests");
const common_1 = require("../common");

@@ -42,6 +43,3 @@ const reflect_1 = require("../common/reflect");

viewChildRefs.set(query.selector, key);
queries[`__mockView_${key}`] = new core_1.ViewChild(`__${query.selector}`, {
read: core_1.ViewContainerRef,
static: query.static
});
queries[`__mockView_${key}`] = new core_1.ViewChild(`__${query.selector}`, Object.assign(Object.assign({}, tests_1.staticFalse), { read: core_1.ViewContainerRef }));
return `

@@ -77,15 +75,5 @@ <div *ngIf="mockRender_${query.selector}" data-key="${query.selector}">

};
let ComponentMock = class ComponentMock {
let ComponentMock = class ComponentMock extends common_1.Mock {
constructor(changeDetector) {
this.__simulateChange = (param) => { };
this.__simulateTouch = () => { };
this.writeValue = (value) => { };
Object.getOwnPropertyNames(component.prototype).forEach((method) => {
if (!this[method]) {
this[method] = () => { };
}
});
(options.outputs || []).forEach((output) => {
this[output.split(':')[0]] = new core_1.EventEmitter();
});
super();
this.__hide = (contentChildSelector) => {

@@ -114,11 +102,5 @@ const key = viewChildRefs.get(contentChildSelector);

}
registerOnChange(fn) {
this.__simulateChange = fn;
}
registerOnTouched(fn) {
this.__simulateTouch = fn;
}
};
ComponentMock = __decorate([
common_1.MockOf(component),
common_1.MockOf(component, outputs),
__metadata("design:paramtypes", [core_1.ChangeDetectorRef])

@@ -125,0 +107,0 @@ ], ComponentMock);

@@ -16,2 +16,4 @@ "use strict";

const platform_browser_1 = require("@angular/platform-browser");
const ng_mocks_1 = require("ng-mocks");
const tests_1 = require("../../tests");
const mock_component_1 = require("./mock-component");

@@ -21,2 +23,3 @@ const child_component_component_1 = require("./test-components/child-component.component");

const empty_component_component_1 = require("./test-components/empty-component.component");
const getter_setter_component_1 = require("./test-components/getter-setter.component");
const simple_component_component_1 = require("./test-components/simple-component.component");

@@ -33,3 +36,3 @@ const template_outlet_component_1 = require("./test-components/template-outlet.component");

__decorate([
core_1.ViewChild(child_component_component_1.ChildComponent, { static: true }),
core_1.ViewChild(child_component_component_1.ChildComponent, Object.assign({}, tests_1.staticTrue)),
__metadata("design:type", child_component_component_1.ChildComponent)

@@ -41,2 +44,3 @@ ], ExampleComponentContainer.prototype, "childComponent", void 0);

template: `
<getter-setter></getter-setter>
<simple-component [someInput]="\'hi\'"

@@ -73,3 +77,3 @@ [someOtherInput]="\'bye\'"

ExampleComponentContainer,
mock_component_1.MockComponents(empty_component_component_1.EmptyComponent, simple_component_component_1.SimpleComponent, template_outlet_component_1.TemplateOutletComponent, child_component_component_1.ChildComponent, custom_form_control_component_1.CustomFormControlComponent),
mock_component_1.MockComponents(empty_component_component_1.EmptyComponent, getter_setter_component_1.GetterSetterComponent, simple_component_component_1.SimpleComponent, template_outlet_component_1.TemplateOutletComponent, child_component_component_1.ChildComponent, custom_form_control_component_1.CustomFormControlComponent),
],

@@ -157,2 +161,10 @@ imports: [

});
it('should set getters and setters to undefined instead of function', () => {
const mockedComponent = ng_mocks_1.MockHelper
.findDirective(fixture.debugElement, getter_setter_component_1.GetterSetterComponent);
expect(mockedComponent.normalMethod).toBeDefined();
expect(mockedComponent.myGetter).not.toBeDefined();
expect(mockedComponent.mySetter).not.toBeDefined();
expect(mockedComponent.normalProperty).not.toBeDefined();
});
describe('ReactiveForms - ControlValueAccessor', () => {

@@ -159,0 +171,0 @@ it('should allow you simulate the component being touched', () => {

@@ -13,18 +13,19 @@ "use strict";

const core_1 = require("@angular/core");
const tests_1 = require("../../../tests");
let TemplateOutletComponent = class TemplateOutletComponent {
};
__decorate([
core_1.ContentChild('block1', { static: false }),
core_1.ContentChild('block1', Object.assign({}, tests_1.staticFalse)),
__metadata("design:type", core_1.TemplateRef)
], TemplateOutletComponent.prototype, "injectedBlock1", void 0);
__decorate([
core_1.ContentChild('block2', { static: false }),
core_1.ContentChild('block2', Object.assign({}, tests_1.staticFalse)),
__metadata("design:type", core_1.TemplateRef)
], TemplateOutletComponent.prototype, "injectedBlock2", void 0);
__decorate([
core_1.ContentChild('block3', { static: false }),
core_1.ContentChild('block3', Object.assign({}, tests_1.staticFalse)),
__metadata("design:type", core_1.TemplateRef)
], TemplateOutletComponent.prototype, "injectedBlock3", void 0);
__decorate([
core_1.ViewChild('block4', { static: false }),
core_1.ViewChild('block4', Object.assign({}, tests_1.staticFalse)),
__metadata("design:type", core_1.ElementRef)

@@ -31,0 +32,0 @@ ], TemplateOutletComponent.prototype, "ownBlock3", void 0);

@@ -16,3 +16,3 @@ "use strict";

const annotations = reflect_1.jitReflector.annotations(declaration);
if (annotations.find((annotation) => annotation.template || annotation.templateUrl)) {
if (annotations.find((annotation) => annotation.template !== undefined || annotation.templateUrl !== undefined)) {
return mock_component_1.MockComponent(declaration);

@@ -19,0 +19,0 @@ }

import { ElementRef, TemplateRef, Type, ViewContainerRef } from '@angular/core';
export declare type MockedDirective<T> = T & {
import { Mock } from '../common';
export declare type MockedDirective<T> = T & Mock & {
__element?: ElementRef;

@@ -4,0 +5,0 @@ __isStructural: boolean;

@@ -24,3 +24,2 @@ "use strict";

function MockDirective(directive) {
var DirectiveMock_1;
const cacheHit = cache.get(directive);

@@ -31,4 +30,15 @@ if (cacheHit) {

const { selector, exportAs, inputs, outputs } = reflect_1.directiveResolver.resolve(directive);
let DirectiveMock = DirectiveMock_1 = class DirectiveMock {
const options = {
exportAs,
inputs,
outputs,
providers: [{
provide: directive,
useExisting: core_1.forwardRef(() => DirectiveMock)
}],
selector,
};
let DirectiveMock = class DirectiveMock extends common_1.Mock {
constructor(element, template, viewContainer) {
super();
this.__element = element;

@@ -38,10 +48,2 @@ this.__template = template;

this.__isStructural = template && viewContainer;
Object.getOwnPropertyNames(directive.prototype).forEach((method) => {
if (!this[method]) {
this[method] = () => { };
}
});
(outputs || []).forEach((output) => {
this[output.split(':')[0]] = new core_1.EventEmitter();
});
this.__render = ($implicit, variables) => {

@@ -55,14 +57,4 @@ if (viewContainer && template) {

};
DirectiveMock = DirectiveMock_1 = __decorate([
common_1.MockOf(directive),
core_1.Directive({
exportAs,
inputs,
outputs,
providers: [{
provide: directive,
useExisting: core_1.forwardRef(() => DirectiveMock_1)
}],
selector
}),
DirectiveMock = __decorate([
common_1.MockOf(directive, outputs),
__param(0, core_1.Optional()),

@@ -75,6 +67,7 @@ __param(1, core_1.Optional()),

], DirectiveMock);
cache.set(directive, DirectiveMock);
return DirectiveMock;
const mockedDirective = core_1.Directive(options)(DirectiveMock);
cache.set(directive, mockedDirective);
return mockedDirective;
}
exports.MockDirective = MockDirective;
//# sourceMappingURL=mock-directive.js.map

@@ -12,2 +12,9 @@ import { EventEmitter } from '@angular/core';

}
export declare class GettersAndSettersDirective {
readonly myGetter: boolean;
mySetter: string;
normalInput?: boolean;
normalProperty: boolean;
normalMethod(): boolean;
}
export declare class ExampleComponentContainer {

@@ -14,0 +21,0 @@ childDirective: ExampleDirective;

@@ -17,2 +17,3 @@ "use strict";

const ng_mocks_1 = require("ng-mocks");
const tests_1 = require("../../tests");
const mock_directive_1 = require("./mock-directive");

@@ -61,2 +62,25 @@ let ExampleDirective = class ExampleDirective {

exports.ExampleStructuralDirective = ExampleStructuralDirective;
let GettersAndSettersDirective = class GettersAndSettersDirective {
constructor() {
this.normalProperty = false;
}
get myGetter() {
return true;
}
set mySetter(value) {
}
normalMethod() {
return this.myGetter;
}
};
__decorate([
core_1.Input(),
__metadata("design:type", Boolean)
], GettersAndSettersDirective.prototype, "normalInput", void 0);
GettersAndSettersDirective = __decorate([
core_1.Directive({
selector: '[getters-and-setters]'
})
], GettersAndSettersDirective);
exports.GettersAndSettersDirective = GettersAndSettersDirective;
let ExampleComponentContainer = class ExampleComponentContainer {

@@ -72,3 +96,3 @@ constructor() {

__decorate([
core_1.ViewChild(ExampleDirective, { static: false }),
core_1.ViewChild(ExampleDirective, Object.assign({}, tests_1.staticFalse)),
__metadata("design:type", ExampleDirective)

@@ -86,2 +110,3 @@ ], ExampleComponentContainer.prototype, "childDirective", void 0);

<input [formControl]="fooControl"/>
<div getters-and-setters></div>
`

@@ -100,3 +125,4 @@ })

mock_directive_1.MockDirective(ExampleDirective),
mock_directive_1.MockDirective(ExampleStructuralDirective)
mock_directive_1.MockDirective(ExampleStructuralDirective),
mock_directive_1.MockDirective(GettersAndSettersDirective),
]

@@ -153,3 +179,11 @@ })

});
it('should set getters and setters to undefined instead of function', () => {
const mockedDirective = ng_mocks_1.MockHelper
.findDirective(fixture.debugElement, GettersAndSettersDirective);
expect(mockedDirective.normalMethod).toBeDefined();
expect(mockedDirective.myGetter).not.toBeDefined();
expect(mockedDirective.mySetter).not.toBeDefined();
expect(mockedDirective.normalProperty).not.toBeDefined();
});
});
//# sourceMappingURL=mock-directive.spec.js.map

@@ -11,8 +11,9 @@ "use strict";

const core_1 = require("@angular/core");
const common_2 = require("../common");
const ng_mocks_1 = require("ng-mocks");
const reflect_1 = require("../common/reflect");
const mock_declaration_1 = require("../mock-declaration");
const cache = new Map();
const neverMockProvidedToken = [
'InjectionToken Application Initializer',
'InjectionToken EventManagerPlugins',
'InjectionToken HammerGestureConfig',
];

@@ -22,2 +23,4 @@ const neverMockProvidedFunction = [

'DomRendererFactory2',
'DomSharedStylesHost',
'EventManager',
'RendererFactory2',

@@ -30,7 +33,7 @@ ];

&& neverMockProvidedToken.includes(provide.toString())) {
return undefined;
return provider;
}
if (typeof provide === 'function'
&& neverMockProvidedFunction.includes(provide.name)) {
return undefined;
return provider;
}

@@ -40,3 +43,3 @@ return {

provide,
useValue: {},
useValue: ng_mocks_1.MockService(provide),
};

@@ -85,3 +88,3 @@ };

core_1.NgModule(MockIt(ngModule)),
common_2.MockOf(ngModule)
ng_mocks_1.MockOf(ngModule)
], ModuleMock);

@@ -113,10 +116,10 @@ moduleMockPointer = ModuleMock;

}
return mock_declaration_1.MockDeclaration(instance);
return ng_mocks_1.MockDeclaration(instance);
});
}
if (declarations.length) {
mockedModule.declarations = flatten(declarations).map(mock_declaration_1.MockDeclaration);
mockedModule.declarations = flatten(declarations).map(ng_mocks_1.MockDeclaration);
}
if (entryComponents.length) {
mockedModule.entryComponents = flatten(entryComponents).map(mock_declaration_1.MockDeclaration);
mockedModule.entryComponents = flatten(entryComponents).map(ng_mocks_1.MockDeclaration);
}

@@ -123,0 +126,0 @@ if (providers.length) {

@@ -14,4 +14,3 @@ "use strict";

const animations_1 = require("@angular/platform-browser/animations");
const mock_component_1 = require("../mock-component");
const mock_module_1 = require("./mock-module");
const ng_mocks_1 = require("ng-mocks");
const test_fixtures_1 = require("./test-fixtures");

@@ -49,4 +48,4 @@ let ComponentSubject = class ComponentSubject {

imports: [
mock_module_1.MockModule(test_fixtures_1.ParentModule),
mock_module_1.MockModule(test_fixtures_1.ModuleWithProvidersModule),
ng_mocks_1.MockModule(test_fixtures_1.ParentModule),
ng_mocks_1.MockModule(test_fixtures_1.ModuleWithProvidersModule),
],

@@ -62,3 +61,3 @@ })

const mockedComponent = fixture.debugElement
.query(platform_browser_1.By.directive(mock_component_1.MockComponent(test_fixtures_1.ExampleComponent)))
.query(platform_browser_1.By.directive(ng_mocks_1.MockComponent(test_fixtures_1.ExampleComponent)))
.componentInstance;

@@ -76,4 +75,4 @@ expect(mockedComponent).not.toBeNull();

imports: [
mock_module_1.MockModule(test_fixtures_1.SameImports1Module),
mock_module_1.MockModule(test_fixtures_1.SameImports2Module),
ng_mocks_1.MockModule(test_fixtures_1.SameImports1Module),
ng_mocks_1.MockModule(test_fixtures_1.SameImports2Module),
],

@@ -100,5 +99,5 @@ })

imports: [
mock_module_1.MockModule(common_1.CommonModule),
mock_module_1.MockModule(platform_browser_1.BrowserModule),
mock_module_1.MockModule(animations_1.BrowserAnimationsModule),
ng_mocks_1.MockModule(common_1.CommonModule),
ng_mocks_1.MockModule(platform_browser_1.BrowserModule),
ng_mocks_1.MockModule(animations_1.BrowserAnimationsModule),
],

@@ -125,3 +124,3 @@ })

imports: [
mock_module_1.MockModule(test_fixtures_1.AppRoutingModule),
ng_mocks_1.MockModule(test_fixtures_1.AppRoutingModule),
],

@@ -149,3 +148,3 @@ })

imports: [
mock_module_1.MockModule(test_fixtures_1.LogicRootModule),
ng_mocks_1.MockModule(test_fixtures_1.LogicRootModule),
],

@@ -170,3 +169,3 @@ })

imports: [
mock_module_1.MockModule(test_fixtures_1.LogicNestedModule),
ng_mocks_1.MockModule(test_fixtures_1.LogicNestedModule),
],

@@ -185,2 +184,18 @@ })

});
describe('WithServiceModule', () => {
beforeEach(testing_1.async(() => {
testing_1.TestBed.configureTestingModule({
declarations: [
test_fixtures_1.CustomWithServiceComponent,
],
imports: [
ng_mocks_1.MockModule(test_fixtures_1.WithServiceModule),
],
});
}));
it('should not throw an error of service method', () => {
const fixture = ng_mocks_1.MockRender('<custom-service></custom-service>');
expect(fixture).toBeDefined();
});
});
//# sourceMappingURL=mock-module.spec.js.map

@@ -35,1 +35,11 @@ import { ElementRef, OnInit, PipeTransform } from '@angular/core';

}
export declare class CustomService {
protected readonly value = "dummy";
getSomething(): string;
}
export declare class CustomWithServiceComponent {
name: string;
constructor(service: CustomService);
}
export declare class WithServiceModule {
}

@@ -169,2 +169,35 @@ "use strict";

exports.ModuleWithProvidersModule = ModuleWithProvidersModule;
let CustomService = class CustomService {
constructor() {
this.value = 'dummy';
}
getSomething() {
return this.value;
}
};
CustomService = __decorate([
core_1.Injectable()
], CustomService);
exports.CustomService = CustomService;
let CustomWithServiceComponent = class CustomWithServiceComponent {
constructor(service) {
this.name = service.getSomething();
}
};
CustomWithServiceComponent = __decorate([
core_1.Component({
selector: 'custom-service',
template: `same imports`
}),
__metadata("design:paramtypes", [CustomService])
], CustomWithServiceComponent);
exports.CustomWithServiceComponent = CustomWithServiceComponent;
let WithServiceModule = class WithServiceModule {
};
WithServiceModule = __decorate([
core_1.NgModule({
providers: [CustomService],
})
], WithServiceModule);
exports.WithServiceModule = WithServiceModule;
//# sourceMappingURL=test-fixtures.js.map
import { PipeTransform, Type } from '@angular/core';
export declare type MockedPipe<T> = T;
export declare function MockPipes(...pipes: Array<Type<PipeTransform>>): Array<Type<PipeTransform>>;
export declare function MockPipe<TPipe extends PipeTransform>(pipe: Type<TPipe>, transform?: TPipe['transform']): Type<TPipe>;
export declare function MockPipe<TPipe extends PipeTransform>(pipe: Type<TPipe>, transform?: TPipe['transform']): Type<MockedPipe<TPipe>>;

@@ -18,3 +18,6 @@ "use strict";

function MockPipe(pipe, transform = defaultTransform) {
const pipeName = reflect_1.pipeResolver.resolve(pipe).name;
const { name } = reflect_1.pipeResolver.resolve(pipe);
const options = {
name,
};
let PipeMock = class PipeMock {

@@ -28,3 +31,3 @@ constructor() {

], PipeMock);
const mockedPipe = core_1.Pipe({ name: pipeName })(PipeMock);
const mockedPipe = core_1.Pipe(options)(PipeMock);
return mockedPipe;

@@ -31,0 +34,0 @@ }

@@ -48,25 +48,46 @@ "use strict";

let fixture;
beforeEach(testing_1.async(() => {
testing_1.TestBed.configureTestingModule({
declarations: [
ExampleComponent,
mock_pipe_1.MockPipe(ExamplePipe, () => 'foo'),
mock_pipe_1.MockPipe(AnotherExamplePipe)
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = testing_1.TestBed.createComponent(ExampleComponent);
fixture.detectChanges();
describe('Base tests', () => {
beforeEach(testing_1.async(() => {
testing_1.TestBed.configureTestingModule({
declarations: [
ExampleComponent,
mock_pipe_1.MockPipe(ExamplePipe, () => 'foo'),
mock_pipe_1.MockPipe(AnotherExamplePipe)
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = testing_1.TestBed.createComponent(ExampleComponent);
fixture.detectChanges();
});
it('should not display the word hi that is output by the unmocked pipe, because it is now mocked', () => {
expect(fixture.debugElement.query(platform_browser_1.By.css('#anotherExamplePipe')).nativeElement.innerHTML).toEqual('');
});
describe('with transform override', () => {
it('should return the result of the provided transform function', () => {
expect(fixture.debugElement.query(platform_browser_1.By.css('#examplePipe')).nativeElement.innerHTML).toEqual('foo');
});
});
});
it('should not display the word hi that is output by the unmocked pipe, because it is now mocked', () => {
expect(fixture.debugElement.query(platform_browser_1.By.css('#anotherExamplePipe')).nativeElement.innerHTML).toEqual('');
});
describe('with transform override', () => {
it('should return the result of the provided transform function', () => {
expect(fixture.debugElement.query(platform_browser_1.By.css('#examplePipe')).nativeElement.innerHTML).toEqual('foo');
describe('Cache check', () => {
beforeEach(testing_1.async(() => {
testing_1.TestBed.configureTestingModule({
declarations: [
ExampleComponent,
mock_pipe_1.MockPipe(ExamplePipe, () => 'bar'),
mock_pipe_1.MockPipe(AnotherExamplePipe)
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = testing_1.TestBed.createComponent(ExampleComponent);
fixture.detectChanges();
});
it('should return the result of the new provided transform function', () => {
expect(fixture.debugElement.query(platform_browser_1.By.css('#examplePipe')).nativeElement.innerHTML).toEqual('bar');
});
});
});
//# sourceMappingURL=mock-pipe.spec.js.map

@@ -5,3 +5,3 @@ import { Type } from '@angular/core';

[key: string]: any;
}>(template: string | Type<MComponent>, params?: TComponent): ComponentFixture<TComponent>;
}>(template: string | Type<MComponent>, params?: TComponent, detectChanges?: boolean): ComponentFixture<TComponent>;
export { MockRender };

@@ -6,3 +6,3 @@ "use strict";

const reflect_1 = require("../common/reflect");
function MockRender(template, params) {
function MockRender(template, params, detectChanges = true) {
let mockedTemplate = '';

@@ -54,3 +54,5 @@ if (typeof template === 'string') {

const fixture = testing_1.TestBed.createComponent(component);
fixture.detectChanges();
if (detectChanges) {
fixture.detectChanges();
}
return fixture;

@@ -57,0 +59,0 @@ }

@@ -39,3 +39,15 @@ "use strict";

});
it('does not detect changes on fixture if detectChanges arg is false', () => {
const fixture = mock_render_1.MockRender(`
before
<render-real-component [content]="mockContent"></render-real-component>
after
`, {
mockContent: 'injected content'
}, false);
expect(fixture.debugElement.nativeElement.innerText).not.toContain('injected content');
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.innerText).toContain('injected content');
});
});
//# sourceMappingURL=mock-render.spec.js.map
{
"name": "ng-mocks",
"version": "9.0.0",
"version": "9.1.0",
"description": "Functions for creating angular mocks",

@@ -68,2 +68,3 @@ "main": "dist/index.js",

"karma-typescript": "^4.0.0",
"puppeteer": "^2.1.1",
"rxjs": "^6.5.3",

@@ -70,0 +71,0 @@ "standard-version": "^4.3.0",

@@ -228,4 +228,10 @@ [![Build Status](https://travis-ci.org/ike18t/ng-mocks.png?branch=master)](https://travis-ci.org/ike18t/ng-mocks)

) as MockedDirective<DependencyDirective>;
fixture.detectChanges();
// now we assert that nothing has been rendered inside of the structural directive by default.
expect(fixture.debugElement.nativeElement.innerText).not.toContain('content');
// and now we render it manually.
mockedDirectiveInstance.__render();
expect(fixture.debugElement.nativeElement.innerText).toContain('content');
// let's pretend Dependency Directive (unmocked) has 'someInput' as an input

@@ -232,0 +238,0 @@ // the input value will be passed into the mocked directive so you can assert on it

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc