mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Split off ServerInitializer.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
b0ecf1c1d8
commit
04a91858c2
18
test/unit/init/ServerInitializer.test.ts
Normal file
18
test/unit/init/ServerInitializer.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ServerInitializer } from '../../../src/init/ServerInitializer';
|
||||
import type { HttpServerFactory } from '../../../src/server/HttpServerFactory';
|
||||
|
||||
describe('ServerInitializer', (): void => {
|
||||
const serverFactory: jest.Mocked<HttpServerFactory> = {
|
||||
startServer: jest.fn(),
|
||||
};
|
||||
|
||||
let initializer: ServerInitializer;
|
||||
beforeAll(async(): Promise<void> => {
|
||||
initializer = new ServerInitializer(serverFactory, 3000);
|
||||
});
|
||||
|
||||
it('starts an HTTP server.', async(): Promise<void> => {
|
||||
await initializer.handle();
|
||||
expect(serverFactory.startServer).toHaveBeenCalledWith(3000);
|
||||
});
|
||||
});
|
||||
@@ -1,24 +1,16 @@
|
||||
import type { Initializer } from '../../../src/init/Initializer';
|
||||
import { Setup } from '../../../src/init/Setup';
|
||||
import type { HttpServerFactory } from '../../../src/server/HttpServerFactory';
|
||||
|
||||
describe('Setup', (): void => {
|
||||
const serverFactory: jest.Mocked<HttpServerFactory> = {
|
||||
startServer: jest.fn(),
|
||||
};
|
||||
const initializer: jest.Mocked<Initializer> = {
|
||||
handleSafe: jest.fn(),
|
||||
} as any;
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
const setup = new Setup(initializer, serverFactory, 'http://localhost:3000/', 3000);
|
||||
const setup = new Setup(initializer);
|
||||
await setup.setup();
|
||||
});
|
||||
|
||||
it('starts an HTTP server.', async(): Promise<void> => {
|
||||
expect(serverFactory.startServer).toHaveBeenCalledWith(3000);
|
||||
});
|
||||
|
||||
it('calls the initializer.', async(): Promise<void> => {
|
||||
expect(initializer.handleSafe).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user