Skip to content

Commit

Permalink
test: updates tests after changing route error res
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianedias committed Sep 12, 2024
1 parent 46f3d0b commit 0bf41bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/app/__tests__/cities.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from "vitest";
import { NextRequest } from "next/server";
import { mockReset } from "vitest-mock-extended";
import mockedDb from "@/tests/unit/db";
Expand All @@ -18,7 +19,7 @@ describe("POST /create", () => {
const response = await GET(request);
expect(response.status).toStrictEqual(400);
expect(await response.text()).toStrictEqual(
"[citites] - Validation error: this is a required field"
"Validation error: this is a required field"
);
});

Expand All @@ -31,7 +32,7 @@ describe("POST /create", () => {
);
const response = await GET(request);
expect(response.status).toStrictEqual(500);
expect(await response.text()).toStrictEqual("[cities]: []");
expect(await response.text()).toStrictEqual('"[]"');
});

it("should return correct cities payload if req is valid", async () => {
Expand Down
15 changes: 6 additions & 9 deletions src/app/__tests__/geolocation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from "vitest";
import { NextRequest } from "next/server";
import { GET } from "../geolocation/route";
import { VOLUNTEER_API_URL } from "@/constants";
Expand Down Expand Up @@ -62,7 +63,7 @@ describe("/geolocation", () => {
expect(response.ok).toStrictEqual(false);
expect(response.status).toStrictEqual(400);
expect(await response.text()).toStrictEqual(
"[geolocation] - Validation error: this must be exactly 8 characters"
"Validation error: this must be exactly 8 characters"
);
});

Expand All @@ -79,7 +80,7 @@ describe("/geolocation", () => {
expect(response.ok).toStrictEqual(false);
expect(response.status).toStrictEqual(400);
expect(await response.text()).toStrictEqual(
'[geolocation] - Validation error: zipcode is "not_found"'
'Validation error: zipcode is "not_found"'
);
});

Expand All @@ -95,9 +96,7 @@ describe("/geolocation", () => {

expect(response.ok).toStrictEqual(false);
expect(response.status).toStrictEqual(500);
expect(await response.text()).toStrictEqual(
'[geolocation]: {\n "ok": false\n}'
);
expect(await response.text()).toStrictEqual('{\n "ok": false\n}');
});
});
describe("With state, city and neighborhood", () => {
Expand Down Expand Up @@ -144,7 +143,7 @@ describe("/geolocation", () => {
expect(response.ok).toStrictEqual(false);
expect(response.status).toStrictEqual(400);
expect(await response.text()).toStrictEqual(
"[geolocation] - Validation error: state is a required field"
"Validation error: state is a required field"
);
});

Expand All @@ -160,9 +159,7 @@ describe("/geolocation", () => {

expect(response.ok).toStrictEqual(false);
expect(response.status).toStrictEqual(500);
expect(await response.text()).toStrictEqual(
'[geolocation]: {\n "ok": false\n}'
);
expect(await response.text()).toStrictEqual('{\n "ok": false\n}');
});
});
});

0 comments on commit 0bf41bd

Please sign in to comment.