Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(`should add metadata only once via wrapper`, () => {
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
const DecoratedEngine = optional(Engine)
const OriginalEngine = ((DecoratedEngine as any) as () => typeof Engine)()
expect(getMetadata(metadataKey, DecoratedEngine!)).toEqual({
optional: true,
})
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
expect(getMetadata(metadataKey, OriginalEngine)).toEqual(undefined)
expect(OriginalEngine).toBe(Engine)
})
it(`should add metadata only once via wrapper`, () => {
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
const DecoratedEngine = optional(Engine)
const OriginalEngine = ((DecoratedEngine as any) as () => typeof Engine)()
expect(getMetadata(metadataKey, DecoratedEngine!)).toEqual({
optional: true,
})
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
expect(getMetadata(metadataKey, OriginalEngine)).toEqual(undefined)
expect(OriginalEngine).toBe(Engine)
})
it(`should add metadata only once via wrapper`, () => {
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
const DecoratedEngine = optional(Engine)
const OriginalEngine = ((DecoratedEngine as any) as () => typeof Engine)()
expect(getMetadata(metadataKey, DecoratedEngine!)).toEqual({
optional: true,
})
expect(getMetadata(metadataKey, Engine)).toEqual(undefined)
expect(getMetadata(metadataKey, OriginalEngine)).toEqual(undefined)
expect(OriginalEngine).toBe(Engine)
})
const getDeps = (target) => {
let types = reflection_1.Reflection.getMetadata("design:paramtypes", target) || [];
let deps = types.map((a) => {
if (a) {
if (a.name !== "Object") {
return a.name;
}
else {
return "props";
}
}
else {
return "";
}
});
return deps;
};
const depsResolver = (options, target) => {
const Input = () => (target, key) => {
reflection_1.Reflection.defineMetadata(utils_1.INPUT_METADATA_KEY, key, target.constructor);
};
exports.Input = Input;
const Input = () => (target: any, key: string) => {
Reflect.defineMetadata(INPUT_METADATA_KEY, key, target.constructor);
};
const getDeps = (target: Function): Array => {
let types:Array = Reflect.getMetadata("design:paramtypes", target) || [];
let deps = types.map((a: Function) => {
if (a) {
if (a.name !== "Object") {
return a.name;
} else {
return "props";
}
} else {
return "";
}
});
return deps;
};