summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/services/telemetry-notification.service.spec.ts
blob: ea1f910e1a65ec0132eb56c983338c3735a4b3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { TestBed } from '@angular/core/testing';

import { configureTestBed } from '~/testing/unit-test-helper';
import { TelemetryNotificationService } from './telemetry-notification.service';

describe('TelemetryNotificationService', () => {
  let service: TelemetryNotificationService;

  configureTestBed({
    providers: [TelemetryNotificationService]
  });

  beforeEach(() => {
    service = TestBed.inject(TelemetryNotificationService);
    spyOn(service.update, 'emit');
  });

  it('should be created', () => {
    expect(service).toBeTruthy();
  });

  it('should set notification visibility to true', () => {
    service.setVisibility(true);
    expect(service.visible).toBe(true);
    expect(service.update.emit).toHaveBeenCalledWith(true);
  });

  it('should set notification visibility to false', () => {
    service.setVisibility(false);
    expect(service.visible).toBe(false);
    expect(service.update.emit).toHaveBeenCalledWith(false);
  });
});