From f0f92c2635952be5820dae162bbdcf810b068c61 Mon Sep 17 00:00:00 2001 From: rickstaa Date: Mon, 10 Oct 2022 12:48:26 +0200 Subject: [PATCH] test: add cache on error test --- tests/api.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/api.test.js b/tests/api.test.js index a6bb092..c05f25a 100644 --- a/tests/api.test.js +++ b/tests/api.test.js @@ -174,6 +174,16 @@ describe("Test /api/", () => { ]); }); + it("should not store cache when error", async () => { + const { req, res } = faker({}, error); + await api(req, res); + + expect(res.setHeader.mock.calls).toEqual([ + ["Content-Type", "image/svg+xml"], + ["Cache-Control", `no-store`], + ]); + }); + it("should set proper cache with clamped values", async () => { { let { req, res } = faker({ cache_seconds: 200000 }, data);