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

app.head.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import opine from "../../mod.ts";import { expect, superdeno } from "../deps.ts";import { describe, it } from "../utils.ts";
describe("HEAD", function () { it("should default to GET", function (done) { const app = opine();
app.get("/deno", function (_req, res) { res.send("deno"); });
superdeno(app) .head("/deno") .expect(200, done); });
it("should output the same headers as GET requests", function (done) { const app = opine();
app.get("/deno", function (_req, res) { // send() detects HEAD res.send("deno"); });
superdeno(app) .get("/deno") .expect(200, function (err, res) { if (err) { return done(err); }
const headers = res.header;
superdeno(app) .get("/deno") .expect(200, function (err, res) { if (err) { return done(err); }
delete headers.date; delete res.header.date; expect(res.header).toEqual(headers); done(); }); }); });});
describe("app.head()", function () { it("should override", function (done) { const app = opine(); let called = false;
app.head("/deno", function (_req, res) { called = true; res.end(""); });
app.get("/deno", function () { throw new Error("should not be called"); });
superdeno(app) .head("/deno") .expect(200, function () { expect(called).toBeTruthy(); done(); }); });});
opine

Version Info

Tagged at
2 years ago