-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathgetProperties.test.ts
More file actions
61 lines (56 loc) · 1.88 KB
/
Copy pathgetProperties.test.ts
File metadata and controls
61 lines (56 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { getProperties as advancedGetProperties } from '../../../src/internals';
import { getProperties as getPropertiesInternal } from '../../../src/providers/s3/apis/internal/getProperties';
import { createMockAmplifyContext } from '../../testUtils/mockAmplifyContext';
jest.mock('../../../src/providers/s3/apis/internal/getProperties');
const mockedGetPropertiesInternal = jest.mocked(getPropertiesInternal);
const mockCtx = createMockAmplifyContext();
describe('getProperties (internal)', () => {
beforeEach(() => {
mockedGetPropertiesInternal.mockResolvedValue({
path: 'output/path/to/mock/object',
});
});
afterEach(() => {
jest.clearAllMocks();
});
it('should pass advanced option locationCredentialsProvider to internal getProperties', async () => {
const useAccelerateEndpoint = true;
const expectedBucketOwner = '012345678901';
const bucket = { bucketName: 'bucket', region: 'us-east-1' };
const customEndpoint = 's3.dualstack.us-east-2.amazonaws.com';
const locationCredentialsProvider = async () => ({
credentials: {
accessKeyId: 'akid',
secretAccessKey: 'secret',
sessionToken: 'token',
expiration: new Date(),
},
});
const result = await advancedGetProperties(mockCtx, {
path: 'input/path/to/mock/object',
options: {
customEndpoint,
useAccelerateEndpoint,
bucket,
expectedBucketOwner,
locationCredentialsProvider,
},
});
expect(mockedGetPropertiesInternal).toHaveBeenCalledTimes(1);
expect(mockedGetPropertiesInternal).toHaveBeenCalledWith(mockCtx, {
path: 'input/path/to/mock/object',
options: {
customEndpoint,
useAccelerateEndpoint,
bucket,
expectedBucketOwner,
locationCredentialsProvider,
},
});
expect(result).toEqual({
path: 'output/path/to/mock/object',
});
});
});