refactor: Rename NotificationChannelInfo to NotificationChannel

This commit is contained in:
Joachim Van Herwegen
2023-02-07 14:35:02 +01:00
parent 61f04487a1
commit 8d31233075
41 changed files with 358 additions and 357 deletions

View File

@@ -1,7 +1,7 @@
import { BasicRepresentation } from '../../../../../src/http/representation/BasicRepresentation';
import type { Representation } from '../../../../../src/http/representation/Representation';
import type { Notification } from '../../../../../src/server/notifications/Notification';
import type { NotificationChannelInfo } from '../../../../../src/server/notifications/NotificationChannelStorage';
import type { NotificationChannel } from '../../../../../src/server/notifications/NotificationChannel';
import {
ConvertingNotificationSerializer,
} from '../../../../../src/server/notifications/serialize/ConvertingNotificationSerializer';
@@ -9,7 +9,7 @@ import type { NotificationSerializer } from '../../../../../src/server/notificat
import type { RepresentationConverter } from '../../../../../src/storage/conversion/RepresentationConverter';
describe('A ConvertingNotificationSerializer', (): void => {
let info: NotificationChannelInfo;
let channel: NotificationChannel;
const notification: Notification = {
'@context': [
'https://www.w3.org/ns/activitystreams',
@@ -26,7 +26,7 @@ describe('A ConvertingNotificationSerializer', (): void => {
let serializer: ConvertingNotificationSerializer;
beforeEach(async(): Promise<void> => {
info = {
channel = {
id: 'id',
topic: 'http://example.com/foo',
type: 'type',
@@ -49,19 +49,19 @@ describe('A ConvertingNotificationSerializer', (): void => {
});
it('can handle input its source can handle.', async(): Promise<void> => {
await expect(serializer.canHandle({ info, notification })).resolves.toBeUndefined();
await expect(serializer.canHandle({ channel, notification })).resolves.toBeUndefined();
source.canHandle.mockRejectedValue(new Error('bad input'));
await expect(serializer.canHandle({ info, notification })).rejects.toThrow('bad input');
await expect(serializer.canHandle({ channel, notification })).rejects.toThrow('bad input');
});
it('returns the source result if there is no accept value.', async(): Promise<void> => {
await expect(serializer.handle({ info, notification })).resolves.toBe(representation);
await expect(serializer.handle({ channel, notification })).resolves.toBe(representation);
expect(converter.handleSafe).toHaveBeenCalledTimes(0);
});
it('converts the source result if there is an accept value.', async(): Promise<void> => {
info.accept = 'text/turtle';
await expect(serializer.handle({ info, notification })).resolves.toBe(representation);
channel.accept = 'text/turtle';
await expect(serializer.handle({ channel, notification })).resolves.toBe(representation);
expect(converter.handleSafe).toHaveBeenCalledTimes(1);
expect(converter.handleSafe).toHaveBeenLastCalledWith({
representation,