'I'm looking for directions on how to cover the Modal in my unit test

I'm looking for directions on how to cover the Modal in my unit test. As soon as I include any invocation of the corresponding hide or show methods in my test I get the following error via Karma Cannot read property 'hide' of undefined, any suggestions?

    import {Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { ModalDirective } from 'ng2-bootstrap/ng2-bootstrap';

import { User } from '../../users/shared/user';
import { UserService } from '../../users/shared/user.service';

@Component({
  moduleId: module.id,
  selector: 'login-modal',
  templateUrl: './login-modal.component.html'
})

export class LoginModalComponent {
  @Input() user: User = new User();
  @Output() onSubmitted = new EventEmitter<User>();
  @ViewChild('loginModal') public loginModal: ModalDirective;
  private errorMessage: string;

  constructor (private userService: UserService) { }

  

    login($event): void {
    if($event){
    this.loginModal.show();
    }else{
    this.loginModal.hide();
    }

  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source