mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Enable stricter test linting
This commit is contained in:
@@ -34,9 +34,10 @@ describe('A WebSocketServerConfigurator', (): void => {
|
||||
// Clearing the logger mock
|
||||
jest.clearAllMocks();
|
||||
server = new EventEmitter() as any;
|
||||
webSocket = new EventEmitter() as any;
|
||||
webSocket.send = jest.fn();
|
||||
webSocket.close = jest.fn();
|
||||
webSocket = {
|
||||
send: jest.fn(),
|
||||
close: jest.fn(),
|
||||
} as any;
|
||||
|
||||
upgradeRequest = new EventEmitter() as any;
|
||||
|
||||
|
||||
@@ -222,7 +222,8 @@ describe('A StaticAssetHandler', (): void => {
|
||||
it('does not handle a request to a known folder URL with parent path segments.', async(): Promise<void> => {
|
||||
const request = { method: 'GET', url: '/foo/bar/folder/../def.css' };
|
||||
const response = createResponse({ eventEmitter: EventEmitter });
|
||||
await expect(handler.canHandle({ request, response } as any)).rejects.toThrow();
|
||||
await expect(handler.canHandle({ request, response } as any))
|
||||
.rejects.toThrow('No static resource configured at /foo/bar/folder/../def.css');
|
||||
});
|
||||
|
||||
it('caches responses when the expires option is set.', async(): Promise<void> => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import type { WebSocket } from 'ws';
|
||||
import { BasicRepresentation } from '../../../../../src/http/representation/BasicRepresentation';
|
||||
import type { NotificationChannel } from '../../../../../src/server/notifications/NotificationChannel';
|
||||
@@ -20,9 +19,10 @@ describe('A WebSocket2023Emitter', (): void => {
|
||||
let emitter: WebSocket2023Emitter;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
webSocket = new EventEmitter() as any;
|
||||
webSocket.send = jest.fn();
|
||||
webSocket.close = jest.fn();
|
||||
webSocket = {
|
||||
send: jest.fn(),
|
||||
close: jest.fn(),
|
||||
} as any;
|
||||
|
||||
socketMap = new WrappedSetMultiMap();
|
||||
|
||||
@@ -46,8 +46,9 @@ describe('A WebSocket2023Emitter', (): void => {
|
||||
});
|
||||
|
||||
it('can send to multiple matching WebSockets.', async(): Promise<void> => {
|
||||
const webSocket2: jest.Mocked<WebSocket> = new EventEmitter() as any;
|
||||
webSocket2.send = jest.fn();
|
||||
const webSocket2: jest.Mocked<WebSocket> = {
|
||||
send: jest.fn(),
|
||||
} as any;
|
||||
|
||||
socketMap.add(channel.id, webSocket);
|
||||
socketMap.add(channel.id, webSocket2);
|
||||
@@ -61,8 +62,9 @@ describe('A WebSocket2023Emitter', (): void => {
|
||||
});
|
||||
|
||||
it('only sends to the matching WebSockets.', async(): Promise<void> => {
|
||||
const webSocket2: jest.Mocked<WebSocket> = new EventEmitter() as any;
|
||||
webSocket2.send = jest.fn();
|
||||
const webSocket2: jest.Mocked<WebSocket> = {
|
||||
send: jest.fn(),
|
||||
} as any;
|
||||
const channel2: NotificationChannel = {
|
||||
...channel,
|
||||
id: 'other',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import type { WebSocket } from 'ws';
|
||||
|
||||
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
@@ -36,9 +35,10 @@ describe('A WebSocket2023Listener', (): void => {
|
||||
let listener: WebSocket2023Listener;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
webSocket = new EventEmitter() as any;
|
||||
webSocket.send = jest.fn();
|
||||
webSocket.close = jest.fn();
|
||||
webSocket = {
|
||||
send: jest.fn(),
|
||||
close: jest.fn(),
|
||||
} as any;
|
||||
|
||||
upgradeRequest = { url: `/foo/123456` } as any;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import type { SetMultiMap } from '../../../../../src/util/map/SetMultiMap';
|
||||
import { WrappedSetMultiMap } from '../../../../../src/util/map/WrappedSetMultiMap';
|
||||
import { flushPromises } from '../../../../util/Util';
|
||||
|
||||
/* eslint-disable jest/prefer-spy-on */
|
||||
describe('A WebSocket2023Storer', (): void => {
|
||||
const channel: NotificationChannel = {
|
||||
id: 'id',
|
||||
|
||||
Reference in New Issue
Block a user