Skip to content

Commit edfdf64

Browse files
committed
feat: auth service 單元測試加上測試後復原資料庫
1 parent 43664ea commit edfdf64

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/auth/auth.service.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ describe("AuthService", () => {
4949
expect(user.statusCode).toEqual(HttpStatus.CREATED);
5050
expect(user.message).toEqual("創建成功");
5151
});
52+
afterEach(async () => {
53+
if (userRepository && userRepository.clear) {
54+
await userRepository.clear();
55+
}
56+
});
5257
it("應該會發生 email、account 已被註冊衝突", async () => {
5358
const createUserDto1: CreateUserDto = {
5459
@@ -68,6 +73,11 @@ describe("AuthService", () => {
6873
});
6974
}
7075
});
76+
afterEach(async () => {
77+
if (userRepository && userRepository.clear) {
78+
await userRepository.clear();
79+
}
80+
});
7181
it("應該會發生 email 已被註冊衝突", async () => {
7282
const test_data1: CreateUserDto = {
7383
@@ -95,6 +105,11 @@ describe("AuthService", () => {
95105
});
96106
}
97107
});
108+
afterEach(async () => {
109+
if (userRepository && userRepository.clear) {
110+
await userRepository.clear();
111+
}
112+
});
98113
it("應該會發生 account 已被註冊衝突", async () => {
99114
const test_data1: CreateUserDto = {
100115

0 commit comments

Comments
 (0)