Skip to content

Commit 5241198

Browse files
author
Umed Khudoiberdiev
committed
fixes #56
1 parent 6c241eb commit 5241198

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/ContainerInstance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class ContainerInstance {
231231
return service.id === identifier;
232232

233233
if (service.type && identifier instanceof Function)
234-
return service.type === identifier || identifier.prototype instanceof service.type;
234+
return service.type === identifier; // todo: not sure why it was here || identifier.prototype instanceof service.type;
235235

236236
return false;
237237
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import "reflect-metadata";
2+
import {Container} from "../../../src/Container";
3+
import {Service} from "../../../src/decorators/Service";
4+
import {expect} from "chai";
5+
6+
describe("github issues > #56 extended class is being overwritten", function() {
7+
8+
beforeEach(() => Container.reset());
9+
10+
it("should work properly", function() {
11+
12+
@Service()
13+
class Rule {
14+
getRule() {
15+
return "very strict rule";
16+
}
17+
}
18+
19+
@Service()
20+
class Whitelist extends Rule {
21+
getWhitelist() {
22+
return ["rule1", "rule2"];
23+
}
24+
}
25+
26+
const whitelist = Container.get(Whitelist);
27+
expect(whitelist.getRule).to.not.be.undefined;
28+
expect(whitelist.getWhitelist).to.not.be.undefined;
29+
whitelist.getWhitelist().should.be.eql(["rule1", "rule2"]);
30+
whitelist.getRule().should.be.equal("very strict rule");
31+
32+
const rule = Container.get(Rule);
33+
expect(rule.getRule).to.not.be.undefined;
34+
expect((rule as Whitelist).getWhitelist).to.be.undefined;
35+
rule.getRule().should.be.equal("very strict rule");
36+
});
37+
38+
});

0 commit comments

Comments
 (0)