All files / src/lib/openapi/mappers strategy.mapper.ts

100% Statements 4/4
83.33% Branches 5/6
100% Functions 3/3
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34            59x                 5x       47x           43x                
import { SchemaMapper } from './mapper';
import { IStrategyConfig } from '../../types/model';
import { StrategySchema } from '../spec/strategy-schema';
import { CreateStrategySchema } from '../spec/create-strategy-schema';
import { UpdateStrategySchema } from '../spec/update-strategy-schema';
 
export class StrategyMapper
    implements
        SchemaMapper<
            StrategySchema,
            IStrategyConfig,
            CreateStrategySchema | UpdateStrategySchema
        >
{
    fromPublic(input: StrategySchema): IStrategyConfig {
        return input;
    }
 
    toPublic(input: IStrategyConfig): StrategySchema {
        return input;
    }
 
    mapInput(
        input: CreateStrategySchema | UpdateStrategySchema,
    ): IStrategyConfig {
        return {
            ...input,
            name: input.name || '',
            parameters: input.parameters || {},
            constraints: input.constraints || [],
        };
    }
}