deno.land / x / opine@2.3.4 / examples / content-negotiation / index.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
74
75
76
77
78
79
80
81
82
83
84
import { superdeno } from "../../test/deps.ts";import { describe, it } from "../../test/utils.ts";import { app } from "./index.ts";
describe("content-negotiation", () => { describe("when accepting HTML", () => { it("should respond with HTML on the root path", (done) => { superdeno(app) .get("/") .accept("text/html") .expect("Content-Type", /text\/html/) .expect( 200, "<ul><li>Deno</li><li>Opine</li><li>Express</li></ul>", done, ); });
it("should respond with HTML on the users path", (done) => { superdeno(app) .get("/users") .accept("text/html") .expect("Content-Type", /text\/html/) .expect( 200, "<ul><li>Deno</li><li>Opine</li><li>Express</li></ul>", done, ); }); });
describe("when accepting text", () => { it("should respond with text on the root path", (done) => { superdeno(app) .get("/") .accept("text/plain") .expect("Content-Type", /text\/plain/) .expect( 200, " - Deno\n - Opine\n - Express\n", done, ); });
it("should respond with text on the users path", (done) => { superdeno(app) .get("/users") .accept("text/plain") .expect("Content-Type", /text\/plain/) .expect( 200, " - Deno\n - Opine\n - Express\n", done, ); }); });
describe("when accepting JSON", () => { it("should respond with JSON on the root path", (done) => { superdeno(app) .get("/") .accept("application/json") .expect("Content-Type", /application\/json/) .expect( 200, '[{"name":"Deno"},{"name":"Opine"},{"name":"Express"}]', done, ); });
it("should respond with JSON on the users path", (done) => { superdeno(app) .get("/users") .accept("application/json") .expect("Content-Type", /application\/json/) .expect( 200, '[{"name":"Deno"},{"name":"Opine"},{"name":"Express"}]', done, ); }); });});
opine

Version Info

Tagged at
2 years ago