-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implements 633 and 576 * Preparing release
- Loading branch information
1 parent
7897f45
commit 581c31f
Showing
5 changed files
with
49 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
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,36 @@ | ||
import { expect } from "chai"; | ||
import { Container, injectable } from "../../src/inversify"; | ||
|
||
describe("Issue 633", () => { | ||
|
||
it("Should expose metadata through context", () => { | ||
|
||
@injectable() | ||
class Logger { | ||
public named: string; | ||
public constructor(named: string) { | ||
this.named = named; | ||
} | ||
} | ||
|
||
const container = new Container(); | ||
|
||
const TYPE = { | ||
Logger: Symbol.for("Logger") | ||
}; | ||
|
||
container.bind<Logger>(TYPE.Logger).toDynamicValue((context) => { | ||
const namedMetadata = context.currentRequest.target.getNamedTag(); | ||
const named = namedMetadata ? namedMetadata.value : "default"; | ||
return new Logger(named); | ||
}); | ||
|
||
const logger1 = container.getNamed<Logger>(TYPE.Logger, "Name1"); | ||
const logger2 = container.getNamed<Logger>(TYPE.Logger, "Name2"); | ||
|
||
expect(logger1.named).to.eq("Name1"); | ||
expect(logger2.named).to.eq("Name2"); | ||
|
||
}); | ||
|
||
}); |