mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { BaseUrlExtractor } from '../../../../../src/init/variables/extractors/BaseUrlExtractor';
|
|
|
|
describe('A BaseUrlExtractor', (): void => {
|
|
let computer: BaseUrlExtractor;
|
|
|
|
beforeEach(async(): Promise<void> => {
|
|
computer = new BaseUrlExtractor();
|
|
});
|
|
|
|
it('extracts the baseUrl parameter.', async(): Promise<void> => {
|
|
await expect(computer.handle({ baseUrl: 'http://example.com/', port: 3333 }))
|
|
.resolves.toBe('http://example.com/');
|
|
});
|
|
|
|
it('uses the port parameter if baseUrl is not defined.', async(): Promise<void> => {
|
|
await expect(computer.handle({ port: 3333 })).resolves.toBe('http://localhost:3333/');
|
|
});
|
|
|
|
it('throws when a Unix Socket Path is provided without a baseUrl.', async(): Promise<void> => {
|
|
await expect(computer.handle({ socket: '/tmp/css.sock' })).rejects
|
|
.toThrow('BaseUrl argument should be provided when using Unix Domain Sockets.');
|
|
});
|
|
|
|
it('defaults to port 3000.', async(): Promise<void> => {
|
|
await expect(computer.handle({})).resolves.toBe('http://localhost:3000/');
|
|
});
|
|
});
|