import { TestBed } from '@angular/core/testing'; import { WptSnackBar } from '@arrow/warpaint/snack-bar'; import { Observable } from 'rxjs'; import { BomNotificationService } from './bom-notification.service'; const wptSnackBarSpyObj = new WptSnackBar(null, null, null, null, null, null); wptSnackBarSpyObj.open = jasmine.createSpy().and.returnValue({ onAction: () => new Observable() }); describe('BomNotificationService', () => { beforeEach(() => TestBed.configureTestingModule({ providers: [ BomNotificationService, { provide: WptSnackBar, useValue: wptSnackBarSpyObj } ] })); it('should be created', () => { const service: BomNotificationService = TestBed.inject(BomNotificationService); expect(service).toBeTruthy(); }); it('should have a notify method', () => { const service: BomNotificationService = TestBed.inject(BomNotificationService); expect(service.notify).toBeDefined(); }); it('should return null if no action is specified ', () => { const service: BomNotificationService = TestBed.inject(BomNotificationService); const returnedValue = service.notify('test'); expect(returnedValue).toBeNull(); }); it('should return an observable if an action is specified ', () => { const service: BomNotificationService = TestBed.inject(BomNotificationService); const returnedValue = service.notify('test', 'action'); expect(returnedValue).toBeTruthy(); }); });