mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { createResponse } from 'node-mocks-http';
|
|
import { WebSocketAdvertiser } from '../../../../src/server/middleware/WebSocketAdvertiser';
|
|
|
|
describe('A WebSocketAdvertiser', (): void => {
|
|
it('writes a ws: socket when given an http: URL.', async(): Promise<void> => {
|
|
const writer = new WebSocketAdvertiser('http://test.example/');
|
|
const response = createResponse();
|
|
await writer.handle({ response } as any);
|
|
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example/' });
|
|
});
|
|
|
|
it('writes a ws: socket when given a ws: URL.', async(): Promise<void> => {
|
|
const writer = new WebSocketAdvertiser('ws://test.example/');
|
|
const response = createResponse();
|
|
await writer.handle({ response } as any);
|
|
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example/' });
|
|
});
|
|
|
|
it('writes a wss: socket when given an https: URL.', async(): Promise<void> => {
|
|
const writer = new WebSocketAdvertiser('https://test.example/');
|
|
const response = createResponse();
|
|
await writer.handle({ response } as any);
|
|
expect(response.getHeaders()).toEqual({ 'updates-via': 'wss://test.example/' });
|
|
});
|
|
|
|
it('writes a wss: socket when given a wss: URL.', async(): Promise<void> => {
|
|
const writer = new WebSocketAdvertiser('wss://test.example/');
|
|
const response = createResponse();
|
|
await writer.handle({ response } as any);
|
|
expect(response.getHeaders()).toEqual({ 'updates-via': 'wss://test.example/' });
|
|
});
|
|
});
|