]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
3111d482b02e14dc7601acad85abca25af868ae3
[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, i18nProviders } 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     providers: i18nProviders
22   });
23
24   beforeEach(() => {
25     fixture = TestBed.createComponent(NotificationsComponent);
26     component = fixture.componentInstance;
27     summaryService = TestBed.inject(SummaryService);
28
29     fixture.detectChanges();
30   });
31
32   it('should create', () => {
33     expect(component).toBeTruthy();
34   });
35
36   it('should subscribe and check if there are running tasks', () => {
37     expect(component.hasRunningTasks).toBeFalsy();
38
39     const task = new ExecutingTask('task', { name: 'name' });
40     summaryService['summaryDataSource'].next({ executing_tasks: [task] });
41
42     expect(component.hasRunningTasks).toBeTruthy();
43   });
44 });