-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: DownloadData refactor (#13073)
* updating type info * update downloadData implementation * fix output type * path dynamic construction * resolve merge conflit * add unit tests for path * update bundle size * update deprecation warning * update test * misc changes * address comments
- Loading branch information
Showing
19 changed files
with
465 additions
and
93 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
53 changes: 53 additions & 0 deletions
53
packages/storage/__tests__/providers/s3/apis/utils/validateStorageOperationInput.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,53 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { | ||
StorageValidationErrorCode, | ||
validationErrorMap, | ||
} from '../../../../../src/errors/types/validation'; | ||
import { validateStorageOperationInput } from '../../../../../src/providers/s3/utils'; | ||
import { | ||
STORAGE_INPUT_KEY, | ||
STORAGE_INPUT_PATH, | ||
} from '../../../../../src/providers/s3/utils/constants'; | ||
|
||
describe('validateStorageOperationInput', () => { | ||
it('should return inputType as STORAGE_INPUT_PATH and objectKey as testPath when input is path as string', () => { | ||
const input = { path: 'testPath' }; | ||
const result = validateStorageOperationInput(input); | ||
expect(result).toEqual({ | ||
inputType: STORAGE_INPUT_PATH, | ||
objectKey: 'testPath', | ||
}); | ||
}); | ||
|
||
it('should return inputType as STORAGE_INPUT_PATH and objectKey as result of path function when input is path as function', () => { | ||
const input = { | ||
path: ({ identityId }: { identityId?: string }) => | ||
`testPath/${identityId}`, | ||
}; | ||
const result = validateStorageOperationInput(input, '123'); | ||
expect(result).toEqual({ | ||
inputType: STORAGE_INPUT_PATH, | ||
objectKey: 'testPath/123', | ||
}); | ||
}); | ||
|
||
it('should return inputType as STORAGE_INPUT_KEY and objectKey as testKey when input is key', () => { | ||
const input = { key: 'testKey' }; | ||
const result = validateStorageOperationInput(input); | ||
expect(result).toEqual({ | ||
inputType: STORAGE_INPUT_KEY, | ||
objectKey: 'testKey', | ||
}); | ||
}); | ||
|
||
it('should throw an error when input is invalid', () => { | ||
const input = { invalid: 'test' } as any; | ||
expect(() => validateStorageOperationInput(input)).toThrow( | ||
validationErrorMap[ | ||
StorageValidationErrorCode.InvalidStorageOperationInput | ||
].message, | ||
); | ||
}); | ||
}); |
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.