import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { RouterTestingModule } from '@angular/router/testing'; import { NotificationBannerComponent, TaBannerStatus } from './notification-banner.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { Router } from '@angular/router'; describe('NotificationBannerComponent', () => { let component: NotificationBannerComponent; let fixture: ComponentFixture; let router: Router; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [RouterTestingModule.withRoutes([]), BrowserAnimationsModule], declarations: [NotificationBannerComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(NotificationBannerComponent); component = fixture.componentInstance; router = TestBed.get(Router); router.initialNavigation(); fixture.detectChanges(); }); it('creates the component', () => { expect(component).toBeTruthy(); }); describe('closeToggle()', () => { it('should toggle the notification banner from on to off', () => { component.isOpen = true; component.closeToggle(); expect(component.isOpen).toBeFalsy(); }) it('should toggle the notification banner from off to on', () => { component.isOpen = false; component.closeToggle(); expect(component.isOpen).toBeTruthy(); }) }); describe('variableSet()', () => { beforeEach(() => { component.isOpen = false; component.message = 'This is just a default message. Please give the message as a parameter or variable.'; component.status = TaBannerStatus.success; }); it('Set the message, status and toggleStatus', () => { const statusMessage: string = 'Alert message!!'; const statusIsOpen: boolean = true; const status: TaBannerStatus = TaBannerStatus.alert; component.variableSet(statusIsOpen, status, statusMessage); expect(component.isOpen).toBeTruthy(); expect(component.message).toBe(statusMessage); expect(component.status).toBe(status); }) it('Set the message, status and toggleStatus', () => { const statusMessage: string = 'Alert message!!'; const statusIsOpen: boolean = false; const status: TaBannerStatus = TaBannerStatus.alert; component.variableSet(statusIsOpen, status, statusMessage); expect(component.isOpen).toBeFalsy(); expect(component.message).toBe(component.message); expect(component.status).toBe(component.status); }) }); describe('displayBanner(): switch case', () => { beforeEach(() => { component.isOpen = false; component.message = 'This is just a default message. Please give the message as a parameter or variable.'; component.status = TaBannerStatus.success; }); afterEach(() => { component.displayBanner(); expect(component.isOpen).toBeFalsy(); expect(component.message).toBe(component.message); expect(component.status).toBe(TaBannerStatus.success); }); it('/cardinal', () => { component.path = '/cardinal'; }) it('/implementation', () => { component.path = '/implementation'; }) it('/color', () => { component.path = '/color'; }) it('/color/usage', () => { component.path = '/color/usage'; }) it('/color/developer-reference', () => { component.path = '/color/developer-reference'; }) it('/iconography', () => { component.path = '/iconography'; }) it('/iconography/usage', () => { component.path = '/iconography/usage'; }) it('/iconography/developer-reference', () => { component.path = '/iconography/developer-reference'; }) it('/iconography/library', () => { component.path = '/iconography/library'; }) it('/typography', () => { component.path = '/typography'; }) it('/typography/usage', () => { component.path = '/typography/usage'; }) it('/typography/developer-reference', () => { component.path = '/typography/developer-reference'; }) it('/typography/responsive', () => { component.path = '/typography/responsive'; }) it('/z-depth', () => { component.path = '/z-depth'; }) it('/z-depth/usage', () => { component.path = '/z-depth/usage'; }) it('/grid', () => { component.path = '/grid'; }) it('/grid/usage', () => { component.path = '/grid/usage'; }) it('/grid/developer-reference', () => { component.path = '/grid/developer-reference'; }) it('/lists', () => { component.path = '/lists'; }) it('/lists/usage', () => { component.path = '/lists/usage'; }) it('/lists/developer-reference', () => { component.path = '/lists/developer-reference'; }) it('/lists/responsive', () => { component.path = '/lists/responsive'; }) it('/lists/style', () => { component.path = '/lists/style'; }) it('/spacing', () => { component.path = '/spacing'; }) it('/spacing/usage', () => { component.path = '/spacing/usage'; }) it('/spacing/developer-reference', () => { component.path = '/spacing/developer-reference'; }) it('/buttons', () => { component.path = '/buttons'; }) it('/buttons/usage', () => { component.path = '/buttons/usage'; }) it('/buttons/developer-reference', () => { component.path = '/buttons/developer-reference'; }) it('/buttons/style', () => { component.path = '/buttons/style'; }) it('/hero', () => { component.path = '/hero'; }) it('/hero/usage', () => { component.path = '/hero/usage'; }) it('/hero/developer-reference', () => { component.path = '/hero/developer-reference'; }) it('/hero/responsive', () => { component.path = '/hero/responsive'; }) it('/tabs', () => { component.path = '/tabs'; }) it('/tabs/usage', () => { component.path = '/tabs/usage'; }) it('/tabs/developer-reference', () => { component.path = '/tabs/developer-reference'; }) it('/tabs/responsive', () => { component.path = '/tabs/responsive'; }) it('/', () => { component.path = '/'; }) }); });