All files / src/app/core/directives identity-provider-capability.directive.ts

90% Statements 9/10
71.42% Branches 10/14
100% Functions 2/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 263x   3x           3x   12x 12x 12x       12x   12x 12x            
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
 
import { IdentityProviderFactory } from 'ish-core/identity-provider/identity-provider.factory';
import { IdentityProviderCapabilities } from 'ish-core/identity-provider/identity-provider.interface';
 
@Directive({
  selector: '[ishIdentityProviderCapability]',
})
export class IdentityProviderCapabilityDirective {
  constructor(
    private templateRef: TemplateRef<unknown>,
    private viewContainer: ViewContainerRef,
    private identityProviderFactory: IdentityProviderFactory
  ) {}
 
  @Input() set ishIdentityProviderCapability(val: keyof IdentityProviderCapabilities) {
    const enabled = this.identityProviderFactory.getInstance().getCapabilities()[val];
 
    if (enabled) {
      this.viewContainer.createEmbeddedView(this.templateRef);
    } else E{
      this.viewContainer.clear();
    }
  }
}