Skip to content

Commit

Permalink
feat(modal-backdrop): added tests to modal-backdrop component
Browse files Browse the repository at this point in the history
  • Loading branch information
svetoldo4444ka committed Nov 27, 2018
1 parent 4cccf98 commit 9bcc762
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/spec/modal-backdrop.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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<ModalBackdropComponent>;
let component: ModalBackdropComponent;
Expand All @@ -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');
Expand All @@ -28,5 +57,6 @@ describe('ModalBackdropComponent tests', () => {
fixture.detectChanges();
modalClass = component.element.nativeElement.classList.contains('in');
expect(modalClass).toBeFalsy();
window.__theme = tempVal;
});
});

0 comments on commit 9bcc762

Please sign in to comment.