deno.land / x / opine@2.3.4 / test / units / app.all.test.ts

app.all.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import opine from "../../mod.ts";import { superdeno } from "../deps.ts";import { describe, it } from "../utils.ts";
describe("app.all()", function () { it("should add a router per method", function (done) { const app = opine();
app.all("/deno", function (req, res) { res.end(req.method); });
superdeno(app) .put("/deno") .expect("PUT", function () { superdeno(app) .get("/deno") .expect("GET", done); }); });
it("should run the callback for a method just once", function (done) { const app = opine(); let n = 0;
app.all("/*", function (_req, _res, next) { if (n++) return done(new Error("DELETE called several times")); next(); });
superdeno(app) .delete("/deno") .expect(404, done); });});
opine

Version Info

Tagged at
2 years ago