-
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
4e11909
commit 8a7fbee
Showing
26 changed files
with
428 additions
and
192 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,40 +13,40 @@ import { decodedToken } from "../../entities/auth"; | |
|
||
class MockUserDataSource implements UserDataSource { | ||
deleteOne(): void { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for deleteOne"); | ||
} | ||
updateOne(): Promise<number> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for updateOne"); | ||
} | ||
create(): Promise<number> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for create"); | ||
} | ||
getAll(): Promise<SearchResult<UserResponseModel>> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for getAll"); | ||
} | ||
getOne(): Promise<UserResponseModel> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for getOne"); | ||
} | ||
getUserLogin(): Promise<AuthUserCredentialsModel | null> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for getUserLogin"); | ||
} | ||
|
||
} | ||
class MockBcryptAdapter extends BcryptAdapter { | ||
async hash(): Promise<string> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for hash"); | ||
} | ||
// compare password | ||
async compare(): Promise<boolean> { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for compare"); | ||
} | ||
} | ||
class MockJwtAdapter extends JwtAdapter { | ||
sign(): string { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for sign"); | ||
} | ||
verify(): JwtPayload | string { | ||
throw new Error("Method not implemented."); | ||
throw new Error("Method not implemented for verify"); | ||
} | ||
} | ||
|
||
|
@@ -801,8 +801,8 @@ describe("User Repository", () => { | |
expect(result).toStrictEqual(expectedData) | ||
}); | ||
}) | ||
describe("IsDeleted", () => { | ||
test("Should return true for a deleted user", async () => { | ||
describe("canUserBeUsed", () => { | ||
test("Should return false for a deleted user", async () => { | ||
const deletedUser: UserResponseModel = { | ||
user_id: 1, | ||
last_name: "anonym_1", | ||
|
@@ -818,10 +818,10 @@ describe("User Repository", () => { | |
} | ||
jest.spyOn(mockUserDataSource, "getOne").mockImplementation(() => Promise.resolve(deletedUser)) | ||
|
||
const result = await userRepository.isDeleted(1); | ||
expect(result).toBe(true) | ||
const result = await userRepository.canUserBeUse(1); | ||
expect(result).toBe(false) | ||
}); | ||
test("Should return false for a non deleted user", async () => { | ||
test("Should return true for a non deleted user", async () => { | ||
const nonDeletedUser: UserResponseModel = { | ||
user_id: 1, | ||
last_name: "Smith", | ||
|
@@ -836,13 +836,31 @@ describe("User Repository", () => { | |
} | ||
jest.spyOn(mockUserDataSource, "getOne").mockImplementation(() => Promise.resolve(nonDeletedUser)) | ||
|
||
const result = await userRepository.isDeleted(1); | ||
const result = await userRepository.canUserBeUse(1); | ||
expect(result).toBe(true) | ||
}); | ||
test("Should return false for a unvalid user", async () => { | ||
const nonDeletedUser: UserResponseModel = { | ||
user_id: 1, | ||
last_name: "Smith", | ||
first_name: "John", | ||
email: "[email protected]", | ||
valid_email: false, | ||
is_admin: false, | ||
organisation: "LOV", | ||
country: "France", | ||
user_planned_usage: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", | ||
user_creation_date: '2023-08-01 10:30:00' | ||
} | ||
jest.spyOn(mockUserDataSource, "getOne").mockImplementation(() => Promise.resolve(nonDeletedUser)) | ||
|
||
const result = await userRepository.canUserBeUse(1); | ||
expect(result).toBe(false) | ||
}); | ||
|
||
test("Should return false for a non existing user", async () => { | ||
jest.spyOn(mockUserDataSource, "getOne").mockImplementation(() => Promise.resolve(null)) | ||
const result = await userRepository.isDeleted(1); | ||
const result = await userRepository.canUserBeUse(1); | ||
expect(result).toBe(false) | ||
}); | ||
}); | ||
|
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
Oops, something went wrong.