-
Notifications
You must be signed in to change notification settings - Fork 0
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
655e376
commit abd65c6
Showing
5 changed files
with
30 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { Request, Response } from "express"; | ||
import {AppLocals} from "../types/app.js"; | ||
import { AppLocals } from "../types/app.js"; | ||
|
||
export class TestPageController { | ||
static getTestPage = (req: Request, res: Response) => { | ||
const { rootDir } = req.app.locals as AppLocals; | ||
res.sendFile(`${rootDir}/static/test.html`); | ||
} | ||
} | ||
res.sendFile(`${rootDir}/static/test.html`); // TODO: use path | ||
}; | ||
} |
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,19 @@ | ||
import { describe, expect, test, vi } from "vitest"; | ||
import { TestPageController } from "../../../src/controllers/testPageController"; | ||
|
||
describe("TestPageController", () => { | ||
test("sends test page file", () => { | ||
const req = { | ||
app: { | ||
locals: { | ||
rootDir: "testRoot" | ||
} | ||
} | ||
} as any; | ||
const res = { | ||
sendFile: vi.fn() | ||
} as any; | ||
TestPageController.getTestPage(req, res); | ||
expect(res.sendFile).toHaveBeenCalledWith("testRoot/static/test.html"); | ||
}); | ||
}); |
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