-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Injecting a property with .then results in undefined (#1570)
- Loading branch information
Showing
5 changed files
with
35 additions
and
6 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 @@ | ||
import { expect } from "chai"; | ||
import { Container, inject, injectable } from "../../src/inversify"; | ||
|
||
describe("Issue 1570", () => { | ||
it("It should not return injected value as undefined if the value contains a .then property but it is not a promise", () => { | ||
const container = new Container(); | ||
|
||
interface Injected { | ||
myProperty: string; | ||
then: () => number; | ||
} | ||
|
||
@injectable() | ||
class ResolveMe { | ||
constructor(@inject("Injected") public injected: Injected) {} | ||
} | ||
|
||
container.bind("Injected").toConstantValue({ | ||
myProperty: "myNewProperty", | ||
then: () => 1 | ||
}); | ||
|
||
const me = container.resolve(ResolveMe); | ||
expect(me.injected.myProperty).to.eql("myNewProperty"); | ||
}); | ||
}); |
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