-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update package and dependencies versions
- Loading branch information
RSamaium
committed
Dec 4, 2023
1 parent
f971d22
commit aae958e
Showing
5 changed files
with
62 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,34 @@ | ||
import { Utils } from '../src' | ||
import { describe, test, expect } from 'vitest' | ||
|
||
describe('Utils.bufferFrom', () => { | ||
// Example test for string input | ||
test('should convert string to Uint8Array', () => { | ||
const input = 'Hello World'; | ||
const result = Utils.bufferFrom(input); | ||
expect(result).toBeInstanceOf(Uint8Array); | ||
expect(result).toEqual(new TextEncoder().encode(input)); | ||
}); | ||
|
||
// Example test for ArrayBuffer input | ||
test('should handle ArrayBuffer input', () => { | ||
const buffer = new ArrayBuffer(10); | ||
const result = Utils.bufferFrom(buffer); | ||
expect(result).toBeInstanceOf(Uint8Array); | ||
expect(result.byteLength).toBe(buffer.byteLength); | ||
}); | ||
|
||
// Example test for input that is a view of ArrayBuffer | ||
test('should handle ArrayBufferView input', () => { | ||
const buffer = new Uint8Array([1, 2, 3]); | ||
const result = Utils.bufferFrom(buffer); | ||
expect(result).toBeInstanceOf(Uint8Array); | ||
expect(result).toEqual(buffer); | ||
}); | ||
|
||
// Example test for unsupported input types | ||
test('should throw error for unsupported input types', () => { | ||
const input = { not: 'supported' }; | ||
expect(() => Utils.bufferFrom(input as any)).toThrow('Input type not supported'); | ||
}); | ||
}); |