mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-03 11:31:39 +00:00
This is a big change, but I think it's a good move, as `vitest` is much more modern than `jest`. I'm excited about the UI watch feature (run `npm run test:ui`), for example - it's really helpful and saves time when debugging tests. I had to adjust a few tests because they had time related issues, but basically we are now testing the same things - even a bit better and less flaky (I hope). What do you think?
34 lines
969 B
JavaScript
34 lines
969 B
JavaScript
const helpers = require("./helpers/global-setup");
|
|
|
|
describe("ipWhitelist directive configuration", () => {
|
|
describe("When IP is not in whitelist", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/noIpWhiteList.js");
|
|
});
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
});
|
|
|
|
it("should reject request with 403 (Forbidden)", async () => {
|
|
const port = global.testPort || 8080;
|
|
const res = await fetch(`http://localhost:${port}`);
|
|
expect(res.status).toBe(403);
|
|
});
|
|
});
|
|
|
|
describe("When whitelist is empty (allow all IPs)", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
|
});
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
});
|
|
|
|
it("should allow request with 200 (OK)", async () => {
|
|
const port = global.testPort || 8080;
|
|
const res = await fetch(`http://localhost:${port}`);
|
|
expect(res.status).toBe(200);
|
|
});
|
|
});
|
|
});
|