-
Notifications
You must be signed in to change notification settings - Fork 168
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
5 changed files
with
133 additions
and
84 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
File renamed without changes.
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
132 changes: 132 additions & 0 deletions
132
packages/web-app-files/tests/unit/helpers/resource/copyMove.spec.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,132 @@ | ||
import * as Resource from '../../../../src/helpers/resource' | ||
|
||
let resourcesToMove | ||
let targetFolder | ||
|
||
describe('copyMove', () => { | ||
beforeEach(() => { | ||
resourcesToMove = [ | ||
{ | ||
id: 'a', | ||
name: 'a', | ||
webDavPath: '/a' | ||
}, | ||
{ | ||
id: 'b', | ||
name: 'b', | ||
webDavPath: '/b' | ||
} | ||
] | ||
targetFolder = { | ||
id: 'target', | ||
path: 'target', | ||
webDavPath: '/target' | ||
} | ||
}) | ||
it('should copy files if no conflicts exist', async () => { | ||
const client = { | ||
files: { | ||
list: async () => { | ||
return [] | ||
}, | ||
copy: jest.fn() | ||
} | ||
} | ||
await Resource.copy( | ||
resourcesToMove, | ||
targetFolder, | ||
client, | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn() | ||
) | ||
expect(client.files.copy).toHaveBeenCalledWith('/a', '/target/a', false) | ||
expect(client.files.copy).toHaveBeenCalledWith('/b', '/target/b', false) | ||
}) | ||
it('should move files if no conflicts exist', async () => { | ||
const client = { | ||
files: { | ||
list: async () => { | ||
return [] | ||
}, | ||
move: jest.fn() | ||
} | ||
} | ||
await Resource.move( | ||
resourcesToMove, | ||
targetFolder, | ||
client, | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn() | ||
) | ||
expect(client.files.move).toHaveBeenCalledWith('/a', '/target/a', false) | ||
expect(client.files.move).toHaveBeenCalledWith('/b', '/target/b', false) | ||
}) | ||
it('should not show message if no conflict exists', async () => { | ||
const client = { | ||
files: { | ||
list: async () => { | ||
return [ | ||
{ | ||
id: 'c', | ||
path: 'target/c', | ||
webDavPath: '/target/c', | ||
name: '/target/c' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
const resolveFileExistsMethod = jest | ||
.fn() | ||
.mockImplementation(() => Promise.resolve({ strategy: 0 } as Resource.ResolveConflict)) | ||
await Resource.resolveAllConflicts( | ||
resourcesToMove, | ||
targetFolder, | ||
client, | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
resolveFileExistsMethod | ||
) | ||
expect(resolveFileExistsMethod).not.toHaveBeenCalled() | ||
}) | ||
it('should show message if conflict exists', async () => { | ||
const client = { | ||
files: { | ||
list: async () => { | ||
return [ | ||
{ | ||
id: 'a', | ||
path: 'target/a', | ||
webDavPath: '/target/a', | ||
name: '/target/a' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
const resolveFileExistsMethod = jest | ||
.fn() | ||
.mockImplementation(() => Promise.resolve({ strategy: 0 } as Resource.ResolveConflict)) | ||
await Resource.resolveAllConflicts( | ||
resourcesToMove, | ||
targetFolder, | ||
client, | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
jest.fn(), | ||
resolveFileExistsMethod | ||
) | ||
expect(resolveFileExistsMethod).toHaveBeenCalled() | ||
}) | ||
}) |
82 changes: 0 additions & 82 deletions
82
packages/web-app-files/tests/unit/helpers/resource/move.spec.ts
This file was deleted.
Oops, something went wrong.