Skip to content

Commit

Permalink
chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Aug 29, 2024
1 parent 6a19c26 commit 90a04eb
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { AmplifyClassV6 } from '@aws-amplify/core';

import { uploadData } from '../../../../../src/providers/s3/apis';
import { MAX_OBJECT_SIZE } from '../../../../../src/providers/s3/utils/constants';
import { createUploadTask } from '../../../../../src/providers/s3/utils';
import {
StorageValidationErrorCode,
validationErrorMap,
} from '../../../../../src/errors/types/validation';
import { putObjectJob } from '../../../../../src/providers/s3/apis/uploadData/putObjectJob';
import { getMultipartUploadHandlers } from '../../../../../src/providers/s3/apis/uploadData/multipart';
import { putObjectJob } from '../../../../../src/providers/s3/apis/internal/uploadData/putObjectJob';
import { getMultipartUploadHandlers } from '../../../../../src/providers/s3/apis/internal/uploadData/multipart';
import { UploadDataInput, UploadDataWithPathInput } from '../../../../../src';

jest.mock('../../../../../src/providers/s3/utils/');
jest.mock('../../../../../src/providers/s3/apis/uploadData/putObjectJob');
jest.mock('../../../../../src/providers/s3/apis/uploadData/multipart');
jest.mock(
'../../../../../src/providers/s3/apis/internal/uploadData/putObjectJob',
);
jest.mock('../../../../../src/providers/s3/apis/internal/uploadData/multipart');

const testPath = 'testPath/object';
const mockCreateUploadTask = createUploadTask as jest.Mock;
Expand Down Expand Up @@ -172,6 +176,7 @@ describe('uploadData with path', () => {
uploadData(testInput);

expect(mockPutObjectJob).toHaveBeenCalledWith(
expect.any(AmplifyClassV6),
testInput,
expect.any(AbortSignal),
expect.any(Number),
Expand Down Expand Up @@ -212,6 +217,7 @@ describe('uploadData with path', () => {

expect(mockPutObjectJob).not.toHaveBeenCalled();
expect(mockGetMultipartUploadHandlers).toHaveBeenCalledWith(
expect.any(AmplifyClassV6),
testInput,
expect.any(Number),
);
Expand Down
Loading

0 comments on commit 90a04eb

Please sign in to comment.