deno.land / x / opine@2.3.4 / test / units / exports.test.ts

exports.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
// deno-lint-ignore-file no-explicit-anyimport { application, opine, request, response, Router } from "../../mod.ts";import { expect, superdeno } from "../deps.ts";import { describe, it } from "../utils.ts";
describe("exports", () => { it("should expose Router", () => { expect(Router).toBeInstanceOf(Function); });
it("should expose the application prototype", () => { expect(application.set).toBeInstanceOf(Function); });
it("should expose the request prototype", () => { expect(request.get).toBeInstanceOf(Function); });
it("should expose the response prototype", () => { expect(response.send).toBeInstanceOf(Function); });
it("should permit modifying the .application prototype", () => { const mockReturnValue = Symbol("test-return-value");
(application as any).mockExtensionMethod = () => { return mockReturnValue; }; expect((opine() as any).mockExtensionMethod()).toEqual(mockReturnValue); });
it("should permit modifying the .request prototype", function (done) { (request as any).foo = function () { return "bar"; }; const app = opine();
app.use(function (req, res, next) { res.end((req as any).foo()); });
superdeno(app) .get("/") .expect("bar", done); });
it("should permit modifying the .response prototype", function (done) { (response as any).foo = function () { (this as any).send("bar"); }; const app = opine();
app.use(function (req, res, next) { (res as any).foo(); });
superdeno(app) .get("/") .expect("bar", done); });});
opine

Version Info

Tagged at
2 years ago