feat: Generalize and extend notification channel type behaviour

This commit is contained in:
Joachim Van Herwegen
2023-01-27 11:53:30 +01:00
parent 7d029a9465
commit c36f15e2da
32 changed files with 1291 additions and 624 deletions

View File

@@ -3,10 +3,7 @@ import type { ResourceIdentifier } from '../../../../src/http/representation/Res
import type { Logger } from '../../../../src/logging/Logger';
import { getLoggerFor } from '../../../../src/logging/LogUtil';
import { KeyValueChannelStorage } from '../../../../src/server/notifications/KeyValueChannelStorage';
import type {
NotificationChannel,
NotificationChannelJson,
} from '../../../../src/server/notifications/NotificationChannel';
import type { NotificationChannel } from '../../../../src/server/notifications/NotificationChannel';
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
import type { ReadWriteLocker } from '../../../../src/util/locking/ReadWriteLocker';
import resetAllMocks = jest.resetAllMocks;
@@ -21,12 +18,6 @@ describe('A KeyValueChannelStorage', (): void => {
const logger = getLoggerFor('mock');
const topic = 'http://example.com/foo';
const identifier = { path: topic };
const json = {
'@context': [ 'https://www.w3.org/ns/solid/notification/v1' ],
type: 'WebSocketSubscription2021',
topic,
} as NotificationChannelJson;
const features = {};
let channel: NotificationChannel;
let internalMap: Map<string, any>;
let internalStorage: KeyValueStorage<string, any>;
@@ -53,12 +44,6 @@ describe('A KeyValueChannelStorage', (): void => {
storage = new KeyValueChannelStorage(internalStorage, locker);
});
describe('#create', (): void => {
it('creates channel based on a notification channel.', async(): Promise<void> => {
expect(storage.create(json, features)).toEqual(channel);
});
});
describe('#get', (): void => {
it('returns undefined if there is no match.', async(): Promise<void> => {
await expect(storage.get('notexists')).resolves.toBeUndefined();