This repository has been archived on 2021-08-17. You can view files and clone it, but cannot push or open issues or pull requests.
TaskBoard/test/app/shared/notifications/notifications.component.spec.ts
2020-05-14 13:12:47 -04:00

65 lines
1.5 KiB
TypeScript

import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { SharedModule } from 'src/app/shared/shared.module';
import {
NotificationsService
} from 'src/app/shared/notifications/notifications.service';
import {
NotificationsComponent
} from 'src/app/shared/notifications/notifications.component';
import { NotificationsServiceMock } from '../../mocks';
describe('Notifications', () => {
let component: NotificationsComponent;
let fixture: ComponentFixture<NotificationsComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
SharedModule
],
providers: [{
provide: NotificationsService, useClass: NotificationsServiceMock
}]
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NotificationsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('can be constructed', () => {
expect(component).toBeTruthy();
});
it('subscribes to note add events', fakeAsync(() => {
const note = { type: 'info' };
(component.notifications as any).addNote(note);
tick(4000);
expect(note.type).toEqual('info clicked');
}));
it('hides notes', fakeAsync(() => {
// tslint:disable-next-line
const hide = component['hide'].bind(component);
const note = { type: 'test' };
component.notes = [note] as any;
hide({});
tick(4000);
expect(note.type).toEqual('test');
hide(note);
tick(4000);
expect(note.type).toEqual('test clicked');
}));
});