All files / decorators/gapi-type gapi-type.ts

100% Statements 17/17
50% Branches 1/2
100% Functions 3/3
100% Lines 17/17

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 227x 7x   7x 4x 4x 4x   4x 4x 4x 4x 4x 4x 4x 4x 4x   4x 4x    
import { ControllerContainerService } from '../../utils/services/controller-service/controller.service';
import Container from '../../utils/container/index';
import { GenericGapiResolversType } from '../../utils/services/controller-service/controller.service';
export function Type<T>(type): Function {
    const currentType = new type();
    Eif (!Container.has(currentType.name)) {
        Container.set(currentType.name, currentType);
    }
    type = { type:  Container.get(currentType.name) };
    return (t: any, propKey: string, descriptor: TypedPropertyDescriptor<any>) => {
        const self = t;
        const originalMethod = descriptor.value;
        const propertyKey = propKey;
        descriptor.value = function (...args: any[]) {
            const returnValue = originalMethod.apply(args);
            Object.assign(returnValue, type);
            return returnValue;
        };
        Container.get(ControllerContainerService).createController(self.constructor.name).setDescriptor(propertyKey, descriptor);
        return descriptor;
    };
}