-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1410309
commit be1c2fc
Showing
5 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from "chai"; | ||
import { Container, injectable } from "../../src/inversify"; | ||
|
||
describe("Container.prototype.resolve", () => { | ||
|
||
it("Should be able to resolve a class that has not binded", () => { | ||
|
||
@injectable() | ||
class Katana { | ||
public hit() { | ||
return "cut!"; | ||
} | ||
} | ||
|
||
@injectable() | ||
class Ninja implements Ninja { | ||
public katana: Katana; | ||
public constructor(katana: Katana) { | ||
this.katana = katana; | ||
} | ||
public fight() { return this.katana.hit(); } | ||
} | ||
|
||
const container = new Container(); | ||
container.bind(Katana).toSelf(); | ||
|
||
const tryGet = () => container.get(Ninja); | ||
expect(tryGet).to.throw("No matching bindings found for serviceIdentifier: Ninja"); | ||
|
||
const ninja = container.resolve(Ninja); | ||
expect(ninja.fight()).to.eql("cut!"); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters