]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
e7c2d97f35aa3cf1f39c9838672c11812c7188a6
[ceph-ci.git] /
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { RouterTestingModule } from '@angular/router/testing';
4
5 import { ToastrModule } from 'ngx-toastr';
6
7 import { configureTestBed } from '../../../../testing/unit-test-helper';
8 import { ExecutingTask } from '../../../shared/models/executing-task';
9 import { SummaryService } from '../../../shared/services/summary.service';
10 import { SharedModule } from '../../../shared/shared.module';
11 import { NotificationsComponent } from './notifications.component';
12
13 describe('NotificationsComponent', () => {
14   let component: NotificationsComponent;
15   let fixture: ComponentFixture<NotificationsComponent>;
16   let summaryService: SummaryService;
17
18   configureTestBed({
19     imports: [HttpClientTestingModule, SharedModule, ToastrModule.forRoot(), RouterTestingModule],
20     declarations: [NotificationsComponent]
21   });
22
23   beforeEach(() => {
24     fixture = TestBed.createComponent(NotificationsComponent);
25     component = fixture.componentInstance;
26     summaryService = TestBed.inject(SummaryService);
27
28     fixture.detectChanges();
29   });
30
31   it('should create', () => {
32     expect(component).toBeTruthy();
33   });
34
35   it('should subscribe and check if there are running tasks', () => {
36     expect(component.hasRunningTasks).toBeFalsy();
37
38     const task = new ExecutingTask('task', { name: 'name' });
39     summaryService['summaryDataSource'].next({ executing_tasks: [task] });
40
41     expect(component.hasRunningTasks).toBeTruthy();
42   });
43 });