Joachim Van Herwegen c216efd62f
feat: Allow for custom CLI and variable options
* feat: (AppRunner) Mechanism to configure cli args and derive componentsjs vars from them implemented

* fix: (AppRunner) tidying

* fix: (AppRunner) tidying up

* fix: (AppRunner) runCli method made sync

* fix; (VarResolver) refactored to multiple files, and other stylistic fixes.

* chore: (AppRunner) Uses builder pattern for yargs base arguments setup to enable better typescript inference

* fix(AppRunner): refactoring AppRunner and VarResolver

* fix(AppRunner): refactoring AppRunner promise handling

* fix(AppRunner): verror dependency removal

* fix: Simplify CLI error handling

* feat: Use same config for both CLI and app instantiation

* fix: Update typings and imports

* feat: Split VariableResolver behaviour to 2 classes

* feat: Move default value behaviour from CLI to ValueComputers

* test: Add unit tests for new CLI classes

* feat: Integrate new CLI configuration with all default configurations

* feat: Add createApp function to AppRunner

* docs: Update comments in CLI-related classes

* fix: Various fixes and refactors

Co-authored-by: damooo <damodara@protonmail.com>
2022-02-11 10:00:12 +01:00

23 lines
801 B
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('defaults to port 3000.', async(): Promise<void> => {
await expect(computer.handle({})).resolves.toBe('http://localhost:3000/');
});
});