From 9bcc762ffd7db2ca84fc64514ba3384c9675ce65 Mon Sep 17 00:00:00 2001 From: svetoldo4444ka Date: Tue, 27 Nov 2018 12:45:44 +0200 Subject: [PATCH] feat(modal-backdrop): added tests to modal-backdrop component --- src/spec/modal-backdrop.component.spec.ts | 34 +++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/spec/modal-backdrop.component.spec.ts b/src/spec/modal-backdrop.component.spec.ts index e0662d0a59..ae449cce35 100644 --- a/src/spec/modal-backdrop.component.spec.ts +++ b/src/spec/modal-backdrop.component.spec.ts @@ -1,6 +1,9 @@ -import { ModalBackdropComponent } from '../modal'; +import { DebugElement } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ModalBackdropComponent } from '../modal'; +import { window } from '../utils/facade/browser'; + describe('ModalBackdropComponent tests', () => { let fixture: ComponentFixture; let component: ModalBackdropComponent; @@ -11,15 +14,41 @@ describe('ModalBackdropComponent tests', () => { }); fixture = TestBed.createComponent(ModalBackdropComponent); component = fixture.componentInstance; + component.isAnimated = true; fixture.detectChanges(); }); it('should get and set isAnimated correctly', () => { + component.isAnimated = false; + expect(component.isAnimated).toBeFalsy(); component.isAnimated = true; expect(component.isAnimated).toBeTruthy(); }); - it('isShown() tests', () => { + it('should get and set isShown correctly', () => { + component.isShown = false; + expect(component.isShown).toBeFalsy(); + component.isShown = true; + expect(component.isShown).toBeTruthy(); + }); + + it('isShown() tests, when bs4', () => { + const tempVal = window.__theme; + window.__theme = 'bs4'; + component.isShown = true; + fixture.detectChanges(); + let modalClass = component.element.nativeElement.classList.contains('show'); + expect(modalClass).toBeTruthy(); + component.isShown = false; + fixture.detectChanges(); + modalClass = component.element.nativeElement.classList.contains('show'); + expect(modalClass).toBeFalsy(); + window.__theme = tempVal; + }); + + it('isShown() tests, when bs3', () => { + const tempVal = window.__theme; + window.__theme = 'bs3'; component.isShown = true; fixture.detectChanges(); let modalClass = component.element.nativeElement.classList.contains('in'); @@ -28,5 +57,6 @@ describe('ModalBackdropComponent tests', () => { fixture.detectChanges(); modalClass = component.element.nativeElement.classList.contains('in'); expect(modalClass).toBeFalsy(); + window.__theme = tempVal; }); });