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 return unique provide from property key", () => {
Metadata.set("controller", "test", Test);
Metadata.set("controller", "test2", Test2);
Metadata.set("controller", "test", Test);
const result = Metadata.getTargetsFromPropertyKey("controller");
expect(result).to.be.an("array");
// expect(result.length).to.equal(2);
expect(result.indexOf(Test) > -1).to.be.true;
expect(result.indexOf(Test2) > -1).to.be.true;
const result2 = Metadata.getTargetsFromPropertyKey("controller2");
expect(result2).to.be.an("array");
expect(result2.length).to.equal(0);
});
});
it("should return unique provide from property key", () => {
Metadata.set("controller", "test", Test);
Metadata.set("controller", "test2", Test2);
Metadata.set("controller", "test", Test);
const result = Metadata.getTargetsFromPropertyKey("controller");
expect(result).to.be.an("array");
// expect(result.length).to.equal(2);
expect(result.indexOf(Test) > -1).to.be.true;
expect(result.indexOf(Test2) > -1).to.be.true;
const result2 = Metadata.getTargetsFromPropertyKey("controller2");
expect(result2).to.be.an("array");
expect(result2.length).to.equal(0);
});
});
it("should set meta on instance", () => {
expect(Metadata.set("metadatakey2", "test2", new Test())).to.equal(undefined);
expect(Metadata.has("metadatakey2", Test)).to.be.true;
});
static getOwnEndpoints(target: Type) {
if (!this.hasEndpoints(target)) {
Metadata.set("endpoints", [], target);
}
return Metadata.getOwn("endpoints", target);
}
static get(target: Type, method: string | symbol): EndpointMetadata {
if (!this.has(target, method)) {
const endpoint = new EndpointMetadata(target, method);
this.getOwnEndpoints(target).push(endpoint);
Metadata.set("endpoints", endpoint, target, method);
}
return Metadata.getOwn("endpoints", target, method);
}