NotificationService.test.ts
1 import { INotification, INotificationService, INotificationServiceSymbol } from 'ipmc-interfaces'; 2 import { Application, NotificationService } from '../../src'; 3 import { describe, expect, test } from 'vitest'; 4 5 describe('NotificationService', () => { 6 const app = new Application(); 7 app.register(NotificationService, INotificationServiceSymbol); 8 test('notification can be added and removed', () => { 9 const service = app.getService<INotificationService>(INotificationServiceSymbol)!; 10 expect(service.notifications.value).toEqual([]); 11 12 const notification: INotification = { 13 autoRemove: false, 14 title: 'test', 15 subTitle: 'subTest', 16 }; 17 18 const sym = service.notify(notification); 19 20 expect(service.notifications.value.length).toBe(1); 21 expect(service.notifications.value[0]).toEqual(notification); 22 23 service.clearNotification(sym); 24 25 expect(service.notifications.value).toEqual([]); 26 }); 27 });