-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update CRT * Update event stream payload encoding function --------- Co-authored-by: Bret Ambrose <[email protected]>
- Loading branch information
1 parent
8248b31
commit 1f92e29
Showing
4 changed files
with
276 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
import * as eventstream_rpc_utils from "./eventstream_rpc_utils"; | ||
|
||
jest.setTimeout(5000); | ||
|
||
test('Encode string payload as base64', async () => { | ||
let encodedPayload = eventstream_rpc_utils.encodePayloadAsString("HelloWorld"); | ||
expect(encodedPayload).toEqual("SGVsbG9Xb3JsZA=="); | ||
}); | ||
|
||
test('Encode ArrayBuffer payload as base64', async () => { | ||
let buffer = new ArrayBuffer(10); | ||
let writeView = new Uint8Array(buffer); | ||
for (let i = 0; i < 10; i++) { | ||
writeView[i] = 65; | ||
} | ||
|
||
let encodedPayload = eventstream_rpc_utils.encodePayloadAsString(buffer); | ||
expect(encodedPayload).toEqual("QUFBQUFBQUFBQQ=="); | ||
}); | ||
|
||
test('Encode view payload as base64', async () => { | ||
let buffer = new ArrayBuffer(10); | ||
let writeView = new Uint8Array(buffer); | ||
for (let i = 0; i < 10; i++) { | ||
writeView[i] = 65; | ||
} | ||
|
||
let view = new DataView(buffer, 1, 8); | ||
|
||
let encodedPayload = eventstream_rpc_utils.encodePayloadAsString(view); | ||
expect(encodedPayload).toEqual("QUFBQUFBQUE="); | ||
}); |
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.