Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(platform-express): Fix hook called twice when using platform-expr…
…ess builder
- Loading branch information
Travis
committed
Apr 27, 2020
1 parent
e1b8b2c
commit 7ca0ade
Showing
2 changed files
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Configuration} from "@tsed/di"; | ||
import {PlatformExpress} from "@tsed/platform-express"; | ||
import * as Sinon from "sinon"; | ||
import { nameOf } from '@tsed/core/src'; | ||
|
||
@Configuration({ | ||
logger: { | ||
level: "off" | ||
} | ||
}) | ||
class Server { | ||
$beforeRoutesInit() { | ||
|
||
} | ||
} | ||
|
||
const sandbox = Sinon.createSandbox(); | ||
describe("bootstrap", () => { | ||
beforeEach(() => { | ||
sandbox.stub(Server.prototype, "$beforeRoutesInit"); | ||
}); | ||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
it("should call once the $beforeRouteInits hooks", async () => { | ||
const server = await PlatformExpress.bootstrap(Server); | ||
|
||
console.log(Array.from(server.injector.keys()).map(nameOf)); | ||
|
||
return Server.prototype.$beforeRoutesInit.should.have.been.calledOnce; | ||
}); | ||
}); |