mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Move runtime config into dedicated component, Closes #67
* Move runtime config into dedicated component, Closes #67 * Migrate FileResourceStore to RuntimeConfig
This commit is contained in:
43
test/unit/init/RuntimeConfig.test.ts
Normal file
43
test/unit/init/RuntimeConfig.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
|
||||
|
||||
describe('RuntimeConfig', (): void => {
|
||||
it('handles undefined args.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig();
|
||||
expect(config.port).toEqual(3000);
|
||||
expect(config.base).toEqual('http://localhost:3000/');
|
||||
});
|
||||
|
||||
it('handles empty args.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig({});
|
||||
expect(config.port).toEqual(3000);
|
||||
expect(config.base).toEqual('http://localhost:3000/');
|
||||
});
|
||||
|
||||
it('handles args with port.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig({ port: 1234 });
|
||||
expect(config.port).toEqual(1234);
|
||||
expect(config.base).toEqual('http://localhost:1234/');
|
||||
});
|
||||
|
||||
it('handles args with base.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig({ base: 'http://example.org/' });
|
||||
expect(config.port).toEqual(3000);
|
||||
expect(config.base).toEqual('http://example.org/');
|
||||
});
|
||||
|
||||
it('handles args with port and base.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig({ port: 1234, base: 'http://example.org/' });
|
||||
expect(config.port).toEqual(1234);
|
||||
expect(config.base).toEqual('http://example.org/');
|
||||
});
|
||||
|
||||
it('handles resetting data.', async(): Promise<void> => {
|
||||
const config = new RuntimeConfig({});
|
||||
expect(config.port).toEqual(3000);
|
||||
expect(config.base).toEqual('http://localhost:3000/');
|
||||
|
||||
config.reset({ port: 1234, base: 'http://example.org/' });
|
||||
expect(config.port).toEqual(1234);
|
||||
expect(config.base).toEqual('http://example.org/');
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
|
||||
import { Setup } from '../../../src/init/Setup';
|
||||
|
||||
describe('Setup', (): void => {
|
||||
@@ -15,16 +16,16 @@ describe('Setup', (): void => {
|
||||
httpServer = {
|
||||
listen: jest.fn(),
|
||||
};
|
||||
setup = new Setup(httpServer, store, aclManager);
|
||||
setup = new Setup(httpServer, store, aclManager, new RuntimeConfig());
|
||||
});
|
||||
|
||||
it('starts an HTTP server.', async(): Promise<void> => {
|
||||
await setup.setup(3000, 'http://localhost:3000/');
|
||||
await setup.setup();
|
||||
expect(httpServer.listen).toHaveBeenCalledWith(3000);
|
||||
});
|
||||
|
||||
it('invokes ACL initialization.', async(): Promise<void> => {
|
||||
await setup.setup(3000, 'http://localhost:3000/');
|
||||
await setup.setup();
|
||||
expect(aclManager.getAcl).toHaveBeenCalledWith({ path: 'http://localhost:3000/' });
|
||||
expect(store.setRepresentation).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user