Unregister & Unsubscribe vom SSE für Keys eingebaut
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SseService } from './sse.service';
|
||||
import { Key } from 'src/model/entitites';
|
||||
|
||||
describe('SseService', () => {
|
||||
let service: SseService;
|
||||
const userId = 'testuserid-54';
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
@@ -15,4 +17,26 @@ describe('SseService', () => {
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
it('should register new SSE clients', () => {
|
||||
|
||||
const res = service.register(userId);
|
||||
expect(service["clients"].has(userId)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should send keys to User', () => {
|
||||
const sub = service.register(userId);
|
||||
const key = new Key();
|
||||
const keyId = 'testkey-123';
|
||||
key.id = keyId;
|
||||
sub.subscribe({
|
||||
next: val => {
|
||||
expect(val.data).toBeTruthy();
|
||||
|
||||
expect(val.data[0]?.id).toBe(keyId)
|
||||
}
|
||||
})
|
||||
service.sendKeysToUsers(userId, [key]);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user