Skip to content

Commit

Permalink
test(app): response status
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei397 committed Oct 18, 2023
1 parent 0ade12b commit 0d7e12d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/oak/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class NestRequest implements Request {
* Get a specific cookie value
*/
cookie(name: string): Promise<string | undefined> {
return this.originalContext.cookies.get(name) || undefined;
return this.originalContext.cookies.get(name);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/app_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,9 @@ export function createCommonTests(
assertEquals(url.pathname, baseURL.pathname);
assert(await req.text() === "");
res.body = "hello world";
assertEquals(res.statusText, "OK");
const originResponse = res.getOriginalResponse();
assertNotEquals(originResponse, res);
});

const res = await fetch(`${baseUrl}`);
Expand Down Expand Up @@ -977,6 +980,7 @@ export function createCommonTests(
assertEquals(req.queries("c"), []);
assertEquals(req.query("a"), "1");
assertEquals(req.query("b"), "2");
assert(!req.query("c"));

const originalRequest = await req.getOriginalRequest();
assertNotStrictEquals(originalRequest, req);
Expand Down Expand Up @@ -1023,12 +1027,14 @@ export function createCommonTests(
assertEquals(await req.cookies(), { a: "1", b: "2" });
assertEquals(await req.cookie("a"), "1");
assertEquals(await req.cookie("b"), "2");
assert(!await req.cookie("c"));

const headers = req.headers();
assertEquals(headers.a, "3");
assertEquals(headers.b, "4");
assertEquals(req.header("a"), "3");
assertEquals(req.header("b"), "4");
assert(!req.header("c"));

res.body = "hello world";
});
Expand Down

0 comments on commit 0d7e12d

Please sign in to comment.