deno.land / x / opine@2.3.4 / test / units / res.location.test.ts

res.location.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { opine } from "../../mod.ts";import { superdeno } from "../deps.ts";import { describe, it } from "../utils.ts";
describe("res", function () { describe(".location(url)", function () { it("should set the header", function (done) { const app = opine();
app.use(function (req, res) { res.location("http://google.com").end(); });
superdeno(app) .get("/") .expect("Location", "http://google.com") .expect(200, done); });
it('should encode "url"', function (done) { const app = opine();
app.use(function (req, res) { res.location("https://google.com?q=\u2603 §10").end(); });
superdeno(app) .get("/") .expect("Location", "https://google.com?q=%E2%98%83%20%C2%A710") .expect(200, done); });
it('should not touch already-encoded sequences in "url"', function (done) { const app = opine();
app.use(function (req, res) { res.location("https://google.com?q=%A710").end(); });
superdeno(app) .get("/") .expect("Location", "https://google.com?q=%A710") .expect(200, done); });
describe('when url is "back"', function () { it('should set location from "Referer" header', function (done) { const app = opine();
app.use(function (req, res) { res.location("back").end(); });
superdeno(app) .get("/") .set("Referer", "/some/page.html") .expect("Location", "/some/page.html") .expect(200, done); });
it('should set location from "Referrer" header', function (done) { const app = opine();
app.use(function (req, res) { res.location("back").end(); });
superdeno(app) .get("/") .set("Referrer", "/some/page.html") .expect("Location", "/some/page.html") .expect(200, done); });
it('should prefer "Referrer" header', function (done) { const app = opine();
app.use(function (req, res) { res.location("back").end(); });
superdeno(app) .get("/") .set("Referer", "/some/page1.html") .set("Referrer", "/some/page2.html") .expect("Location", "/some/page2.html") .expect(200, done); });
it('should set the header to "/" without referrer', function (done) { const app = opine();
app.use(function (req, res) { res.location("back").end(); });
superdeno(app) .get("/") .expect("Location", "/") .expect(200, done); }); }); });});
opine

Version Info

Tagged at
2 years ago