-
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.
[Chore] Refactor Storage Options (#13613)
* refactor storage options naming * update casts * add bytelength base test
- Loading branch information
Showing
7 changed files
with
106 additions
and
78 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/storage/__tests__/providers/s3/apis/uploadData/byteLength.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,39 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { byteLength } from '../../../../../src/providers/s3/apis/uploadData/byteLength'; | ||
|
||
describe('byteLength', () => { | ||
it('returns 0 for null or undefined', () => { | ||
expect(byteLength(undefined)).toBe(0); | ||
expect(byteLength(null)).toBe(0); | ||
}); | ||
|
||
it('calculates byte length correctly for ASCII strings', () => { | ||
expect(byteLength('hello')).toBe(5); | ||
}); | ||
|
||
it('calculates byte length correctly for multi-byte characters', () => { | ||
expect(byteLength('èちは')).toBe(8); | ||
}); | ||
|
||
it('handles Uint8Array correctly', () => { | ||
const input = new Uint8Array([1, 2, 3]); | ||
expect(byteLength(input)).toBe(3); | ||
}); | ||
|
||
it('handles ArrayBuffer correctly', () => { | ||
const buffer = new ArrayBuffer(8); | ||
expect(byteLength(buffer)).toBe(8); | ||
}); | ||
|
||
it('handles File object correctly', () => { | ||
const file = new Blob(['hello']); | ||
expect(byteLength(file)).toBe(5); | ||
}); | ||
|
||
it('returns undefined for unsupported types', () => { | ||
const input = { unsupportedType: true }; | ||
expect(byteLength(input)).toBeUndefined(); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
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