-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_test.ts
49 lines (40 loc) · 1.3 KB
/
create_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
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
import { createResponse } from "./create.ts";
import { equalsResponse } from "./equal.ts";
import { assert, assertEquals, describe, it } from "./_dev_deps.ts";
describe("createResponse", () => {
it("should return new response", async () => {
const init = new Response();
const response = createResponse(init);
assert(init !== response);
assert(await equalsResponse(init, response, true));
});
it("should return partial updated response", () => {
const init = new Response(null, { status: 201 });
const response = createResponse(init, { status: 202 });
assertEquals(response.status, 202);
});
it("should extern body", async () => {
const response = createResponse(new Response("test"), { status: 202 });
assert(
await equalsResponse(
response,
new Response("test", { status: 202 }),
true,
),
);
});
it("should not merge headers", async () => {
const response = createResponse(
new Response(null, { headers: { "x-test": "test" } }),
{ headers: { "x-test2": "test2" } },
);
assert(
await equalsResponse(
response,
new Response(null, { headers: { "x-test2": "test2" } }),
true,
),
);
});
});