-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chore/unit-test-and-linter-fixes' of github.com:internx…
…t/drive-server-wip into chore/unit-test-and-linter-fixes
- Loading branch information
Showing
10 changed files
with
184 additions
and
59 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
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 |
---|---|---|
|
@@ -11,8 +11,57 @@ describe('PrivateSharingUseCase', () => { | |
|
||
const mockRepository = { | ||
findByOwner: jest.fn(), | ||
findBySharedWith: jest.fn(), | ||
}; | ||
|
||
const user = User.build({ | ||
userId: 'JohnDoe userId', | ||
name: 'John', | ||
lastname: 'Doe', | ||
uuid: v4(), | ||
email: '[email protected]', | ||
username: '[email protected]', | ||
bridgeUser: '[email protected]', | ||
password: '', | ||
mnemonic: 'john doe mnemonic', | ||
referrer: v4(), | ||
referralCode: v4(), | ||
credit: 0, | ||
hKey: new Buffer('john doe hKey'), | ||
rootFolderId: 1, | ||
errorLoginCount: 0, | ||
isEmailActivitySended: 1, | ||
lastResend: new Date(), | ||
syncDate: new Date(), | ||
welcomePack: true, | ||
registerCompleted: true, | ||
id: 0, | ||
secret_2FA: '', | ||
backupsBucket: '', | ||
sharedWorkspace: false, | ||
tempKey: '', | ||
avatar: '', | ||
}); | ||
|
||
const folders: Folder[] = [ | ||
Folder.build({ | ||
id: 0, | ||
parentId: null, | ||
name: 'FolderTwo', | ||
bucket: 'bucketTwo', | ||
userId: user.id, | ||
uuid: v4(), | ||
plainName: 'FolderTwo', | ||
encryptVersion: '03-aes', | ||
deleted: false, | ||
removed: false, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
removedAt: null, | ||
deletedAt: null, | ||
}), | ||
]; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
|
@@ -39,54 +88,6 @@ describe('PrivateSharingUseCase', () => { | |
|
||
describe('getSharedFoldersByOwner', () => { | ||
it('should return the folders shared by a specific user', async () => { | ||
const user = User.build({ | ||
userId: 'JohnDoe userId', | ||
name: 'John', | ||
lastname: 'Doe', | ||
uuid: v4(), | ||
email: '[email protected]', | ||
username: '[email protected]', | ||
bridgeUser: '[email protected]', | ||
password: '', | ||
mnemonic: 'john doe mnemonic', | ||
referrer: v4(), | ||
referralCode: v4(), | ||
credit: 0, | ||
hKey: new Buffer('john doe hKey'), | ||
rootFolderId: 1, | ||
errorLoginCount: 0, | ||
isEmailActivitySended: 1, | ||
lastResend: new Date(), | ||
syncDate: new Date(), | ||
welcomePack: true, | ||
registerCompleted: true, | ||
id: 0, | ||
secret_2FA: '', | ||
backupsBucket: '', | ||
sharedWorkspace: false, | ||
tempKey: '', | ||
avatar: '', | ||
}); | ||
|
||
const folders: Folder[] = [ | ||
Folder.build({ | ||
id: 0, | ||
parentId: null, | ||
name: 'FolderTwo', | ||
bucket: 'bucketTwo', | ||
userId: user.id, | ||
uuid: v4(), | ||
plainName: 'FolderTwo', | ||
encryptVersion: '03-aes', | ||
deleted: false, | ||
removed: false, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
removedAt: null, | ||
deletedAt: null, | ||
}), | ||
]; | ||
|
||
jest | ||
.spyOn(privateSharingRespository, 'findByOwner') | ||
.mockResolvedValue(folders); | ||
|
@@ -110,5 +111,30 @@ describe('PrivateSharingUseCase', () => { | |
order, | ||
); | ||
}); | ||
|
||
it('should return the folders shared with a specific user', async () => { | ||
jest | ||
.spyOn(privateSharingRespository, 'findBySharedWith') | ||
.mockResolvedValue(folders); | ||
|
||
const offset = 0; | ||
const limit = 10; | ||
const order: [string, string][] = [['createdAt', 'DESC']]; | ||
|
||
const result = await privateSharingUseCase.getSharedFoldersBySharedWith( | ||
user, | ||
offset, | ||
limit, | ||
order, | ||
); | ||
|
||
expect(result).toEqual(folders); | ||
expect(privateSharingRespository.findBySharedWith).toHaveBeenCalledWith( | ||
user.uuid, | ||
offset, | ||
limit, | ||
order, | ||
); | ||
}); | ||
}); | ||
}); |
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