-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
18 changed files
with
1,184 additions
and
966 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
49 changes: 49 additions & 0 deletions
49
tdrive/backend/node/test/unit/core/services/user/services/users/user-service.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,49 @@ | ||
import { jest } from "@jest/globals"; | ||
import { UserServiceImpl } from "../../../../../../../src/services/user/services/users/user-service"; | ||
import Repository from "../../../../../../../src/core/platform/services/database/services/orm/repository/repository"; | ||
import { DriveFile } from "../../../../../../../src/services/documents/entities/drive-file"; | ||
import { randomUUID } from "crypto"; | ||
import User, { UserPrimaryKey } from "../../../../../../../src/services/user/entities/user"; | ||
describe("The UsersService", () => { | ||
|
||
const subj: UserServiceImpl = new UserServiceImpl(); | ||
|
||
beforeEach(async () => { | ||
const mockRepository = { | ||
save: jest.fn(() => Promise.resolve(null)), | ||
}; | ||
|
||
const mockConfig = { | ||
get: jest.fn(() => Promise.resolve("00000")), | ||
} | ||
|
||
subj.driveFileRepository = mockRepository as unknown as Repository<DriveFile>; | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test("Test creating default folder for the user", async () => { | ||
//given | ||
const user = { id: randomUUID()}; | ||
let actualDoc:DriveFile = null; | ||
let saveSpy = jest.spyOn(subj.driveFileRepository, "save"); | ||
saveSpy.mockImplementation( | ||
jest.fn(async (doc: DriveFile) => { | ||
actualDoc = doc; | ||
}) | ||
); | ||
|
||
//when | ||
await subj.createUserRootFolder(user as User) | ||
|
||
//then | ||
expect(actualDoc).toBeDefined(); | ||
expect(actualDoc.id).toBeDefined(); | ||
expect(actualDoc.id.startsWith("user_")).toBeTruthy() | ||
expect(actualDoc.parent_id).toBeNull(); | ||
|
||
}) | ||
|
||
}); |
Oops, something went wrong.