test: add the log facilities and configuration pass-through test
This commit is contained in:
parent
96f96424b6
commit
87a57d8c8b
1 changed files with 22 additions and 0 deletions
|
@ -179,6 +179,28 @@ describe("SVRouter", () => {
|
||||||
expect(res.passedThroughPass2).toBe(true);
|
expect(res.passedThroughPass2).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should pass through log facilities and configuration objects in routes", () => {
|
||||||
|
const req = {
|
||||||
|
method: "GET",
|
||||||
|
parsedURL: { pathname: "/anything" },
|
||||||
|
params: null
|
||||||
|
};
|
||||||
|
const res = {};
|
||||||
|
const logFacilities = {};
|
||||||
|
const config = {};
|
||||||
|
const passedThrough = {};
|
||||||
|
|
||||||
|
router.pass((req, res, logFacilities, config) => {
|
||||||
|
passedThrough.logFacilities = logFacilities;
|
||||||
|
passedThrough.config = config;
|
||||||
|
});
|
||||||
|
|
||||||
|
router(req, res, logFacilities, config, () => {});
|
||||||
|
|
||||||
|
expect(passedThrough.logFacilities).toBe(logFacilities);
|
||||||
|
expect(passedThrough.config).toBe(config);
|
||||||
|
});
|
||||||
|
|
||||||
test("should throw an error if method is not a string in route", () => {
|
test("should throw an error if method is not a string in route", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
router.route(123, "/path", () => {});
|
router.route(123, "/path", () => {});
|
||||||
|
|
Loading…
Reference in a new issue