-
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.
fix: rework upload implementation, add tests and new configurations
- Loading branch information
1 parent
c032dd1
commit ca69b14
Showing
15 changed files
with
848 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"editor.formatOnSave": true | ||
} | ||
"editor.formatOnSave": true, | ||
"jest.autoEnable": 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Upload } from '@DOSUpload/utils/Upload.ts' | ||
// tslint:disable-next-line: no-var-requires | ||
const AWS = require('aws-sdk') | ||
|
||
describe('DOSUpload utils', () => { | ||
afterEach(() => AWS.clearAllMocks()) | ||
it('Upload init', async () => { | ||
const uploadFiles: jest.Mock = AWS.spyOn('S3', 'upload').mockReturnValue({ | ||
promise: () => Promise.resolve(), | ||
on: () => Promise.resolve(), | ||
}) | ||
|
||
const test = new Upload({ | ||
digitalSourceFolder: './Tests/fixtures/', | ||
digitalGlobExpressions: ['**'], | ||
digitalAcl: 'test', | ||
digitalFlattenFolders: false, | ||
digitalEndpoint: { | ||
parameters: { username: 'test', password: 'test' }, | ||
scheme: 'test', | ||
}, | ||
digitalRegion: 'test', | ||
digitalBucket: 'test', | ||
digitalCredentials: 'test', | ||
}) | ||
|
||
const normalizePaths = jest.spyOn(test, 'normalizeKeyPath') | ||
|
||
await test.init() | ||
|
||
expect(uploadFiles.mock.calls).toMatchSnapshot() | ||
expect(normalizePaths).toHaveBeenCalledTimes(3) | ||
expect(normalizePaths).toHaveBeenNthCalledWith( | ||
1, | ||
'Tests/fixtures/file-v1.0.1.txt' | ||
) | ||
expect(normalizePaths).toHaveBeenNthCalledWith( | ||
2, | ||
'Tests/fixtures/file1-v1.2.1.txt' | ||
) | ||
expect(normalizePaths).toHaveBeenNthCalledWith( | ||
3, | ||
'Tests/fixtures/file2-v1.3.1.json' | ||
) | ||
expect(normalizePaths.mock.results).toEqual([ | ||
{ type: 'return', value: 'file-v1.0.1.txt' }, | ||
{ type: 'return', value: 'file1-v1.2.1.txt' }, | ||
{ type: 'return', value: 'file2-v1.3.1.json' }, | ||
]) | ||
}) | ||
}) |
Oops, something went wrong.