Skip to content

Commit

Permalink
perf: cc duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Nov 23, 2020
1 parent 73f607a commit 4e81ff9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/mock-component/mock-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ComponentMockBase extends MockControlValueAccessor implements AfterContent
}

public ngAfterContentInit(): void {
const config: any = this.__ngMocksConfig?.config;
const config = (this.__ngMocksConfig as any).config;
if (!(this as any).__rendered && config && config.render) {
for (const block of Object.keys(config.render)) {
const { $implicit, variables } =
Expand All @@ -45,11 +45,11 @@ class ComponentMockBase extends MockControlValueAccessor implements AfterContent
}

private __ngMocksInstall(changeDetector: ChangeDetectorRef): void {
const refs: any = this.__ngMocksConfig?.viewChildRefs;
const refs = (this.__ngMocksConfig as any).viewChildRefs;

// Providing method to hide any @ContentChild based on its selector.
(this as any).__hide = (contentChildSelector: string) => {
const key = refs?.get(contentChildSelector);
const key = refs.get(contentChildSelector);
if (key) {
(this as any)[`mockRender_${contentChildSelector}`] = false;
changeDetector.detectChanges();
Expand All @@ -58,7 +58,7 @@ class ComponentMockBase extends MockControlValueAccessor implements AfterContent

// Providing a method to render any @ContentChild based on its selector.
(this as any).__render = (contentChildSelector: string, $implicit?: any, variables?: Record<keyof any, any>) => {
const key = refs?.get(contentChildSelector);
const key = refs.get(contentChildSelector);
let templateRef: TemplateRef<any>;
let viewContainer: ViewContainerRef;
if (key) {
Expand Down
2 changes: 1 addition & 1 deletion lib/mock-directive/mock-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DirectiveMockBase extends MockControlValueAccessor implements OnInit {
}

public ngOnInit(): void {
const config: any = this.__ngMocksConfig?.config;
const config = (this.__ngMocksConfig as any).config;
if (config?.render) {
const { $implicit, variables } =
config.render !== true
Expand Down
2 changes: 1 addition & 1 deletion lib/mock-helper/mock-helper.attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (label: string, attr: 'inputs' | 'outputs', ...args: any[]) => {
}

/* istanbul ignore if */
for (const attrDef of meta[attr] || []) {
for (const attrDef of meta[attr] || /* istanbul ignore next */ []) {
const [prop, alias = ''] = attrDef.split(':', 2).map(v => v.trim());
if (!alias && prop !== sel) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/mock/clone-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default (mockType: AnyType<any>, providers?: any[]): { providers: Provide
let setNgValueAccessor: boolean | undefined;
const resolutions = new Map();

for (const providerDef of flatten(providers || [])) {
for (const providerDef of flatten(providers || /* istanbul ignore next */ [])) {
const provide =
providerDef && typeof providerDef === 'object' && providerDef.provide ? providerDef.provide : providerDef;
if (provide === NG_VALIDATORS) {
Expand Down

0 comments on commit 4e81ff9

Please sign in to comment.