- Unify test data for nonexistence of an object/string and collection. - Introduce more test through adding missing test data to existing tests. - Improve logic for checking absence of values to match tests. - Add missing tests for absent value validation. - Update documentation to include shared test functionality.
30 lines
778 B
TypeScript
30 lines
778 B
TypeScript
import { IPipe } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipe';
|
|
import { IPipeFactory } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeFactory';
|
|
|
|
export class PipeFactoryStub implements IPipeFactory {
|
|
private readonly pipes = new Array<IPipe>();
|
|
|
|
public get(pipeName: string): IPipe {
|
|
const result = this.pipes.find((pipe) => pipe.name === pipeName);
|
|
if (!result) {
|
|
throw new Error(`pipe not registered: "${pipeName}"`);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public withPipe(pipe: IPipe) {
|
|
if (!pipe) {
|
|
throw new Error('missing pipe');
|
|
}
|
|
this.pipes.push(pipe);
|
|
return this;
|
|
}
|
|
|
|
public withPipes(pipes: IPipe[]) {
|
|
for (const pipe of pipes) {
|
|
this.withPipe(pipe);
|
|
}
|
|
return this;
|
|
}
|
|
}
|