-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from boostcampwm2023/feat/90-diaries-list-api
[Feat] 전체 일기 목록 API 구현 및 e2e 테스트 작성
- Loading branch information
Showing
5 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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,55 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { INestApplication } from "@nestjs/common"; | ||
import * as request from "supertest"; | ||
import { AppModule } from "../src/app.module"; | ||
import { ValidationPipe } from "@nestjs/common"; | ||
|
||
describe("AppController (e2e)", () => { | ||
let app: INestApplication; | ||
let accessToken: string; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
app.enableCors(); | ||
app.useGlobalPipes(new ValidationPipe()); | ||
|
||
await app.init(); | ||
|
||
const signInPost = await request(app.getHttpServer()) | ||
.post("/auth/signin") | ||
.send({ | ||
userId: "commonUser", | ||
password: process.env.COMMON_USER_PASS, | ||
}); | ||
|
||
accessToken = signInPost.body.accessToken; | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.close(); | ||
}); | ||
|
||
it("정상 요청 시 200 OK 응답", async () => { | ||
const postResponse = await request(app.getHttpServer()) | ||
.get("/diaries") | ||
.set("Authorization", `Bearer ${accessToken}`) | ||
.expect(200); | ||
}); | ||
|
||
it("정상 요청 시 200 OK 응답", async () => { | ||
const postResponse = await request(app.getHttpServer()) | ||
.get("/diaries") | ||
.set("Authorization", `Bearer ${accessToken}`) | ||
.expect(200); | ||
}); | ||
|
||
it("액세스 토큰 없이 요청 시 401 Unauthorized 응답", async () => { | ||
const postResponse = await request(app.getHttpServer()) | ||
.get("/diaries") | ||
.expect(401); | ||
}); | ||
}); |