-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2285983
commit 6e403a3
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
server/src/__tests__/integration/controllers/comment/get.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createApp } from "../../utils/setup.util"; | ||
import authRoutes from "../../../../routes/auth.route"; | ||
import commentRoutes from "../../../../routes/comment.route"; | ||
|
||
import { existingUserLogin } from "../../utils/auth.util"; | ||
import { customGet } from "../../utils/custom.util"; | ||
|
||
const app = createApp(); | ||
|
||
// Global variables | ||
let user_id: number; | ||
let token: string; | ||
|
||
describe("Comments controller GET tests", () => { | ||
beforeAll(async () => { | ||
app.use("/api/auth", authRoutes); | ||
app.use("/api/comments", commentRoutes); | ||
|
||
const login = await existingUserLogin(app); | ||
if (login.status !== 200) throw new Error("Failed existingUser login!"); | ||
user_id = login.userId; | ||
token = login.token; | ||
}); | ||
|
||
it("responds 200 for GET /api/comments/", async () => { | ||
const endpoint = "/api/comments/count?postId=1"; | ||
const res = await customGet(app, endpoint, token); | ||
expect(res.status).toBe(200); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
server/src/__tests__/integration/controllers/friend/get.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { createApp } from "../../utils/setup.util"; | ||
import authRoutes from "../../../../routes/auth.route"; | ||
import friendRoutes from "../../../../routes/friend.route"; | ||
|
||
import { existingUserLogin } from "../../utils/auth.util"; | ||
import { customGet } from "../../utils/custom.util"; | ||
|
||
const app = createApp(); | ||
|
||
// Global variables | ||
let user_id: number; | ||
let token: string; | ||
|
||
describe("Friends controller GET tests", () => { | ||
beforeAll(async () => { | ||
app.use("/api/auth", authRoutes); | ||
app.use("/api/friends", friendRoutes); | ||
|
||
const login = await existingUserLogin(app); | ||
if (login.status !== 200) throw new Error("Failed existingUser login!"); | ||
user_id = login.userId; | ||
token = login.token; | ||
}); | ||
|
||
it("responds 200 for GET /api/friends/", async () => { | ||
const endpoint = "/api/friends/"; | ||
const res = await customGet(app, endpoint, token); | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it("responds 200 for GET /api/friends/followers", async () => { | ||
const endpoint = "/api/friends/followers"; | ||
const res = await customGet(app, endpoint, token); | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it("responds 200 for GET /api/friends/following", async () => { | ||
const endpoint = "/api/friends/following"; | ||
const res = await customGet(app, endpoint, token); | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it("responds 200 for GET /api/friends/findPeople", async () => { | ||
const endpoint = "/api/friends/findPeople"; | ||
const res = await customGet(app, endpoint, token); | ||
expect(res.status).toBe(200); | ||
}); | ||
}); |