Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Dec 3, 2024
1 parent d882f64 commit ae074db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/snaps-controllers/coverage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"branches": 92.89,
"branches": 92.91,
"functions": 96.71,
"lines": 98,
"lines": 98.01,
"statements": 97.71
}
12 changes: 11 additions & 1 deletion packages/snaps-controllers/src/test-utils/webview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { base64ToBytes, bytesToString } from '@metamask/utils';
import {
base64ToBytes,
bytesToBase64,
bytesToString,
stringToBytes,
} from '@metamask/utils';

import { WebViewMessageStream } from '../services/webview/WebViewMessageStream';

Expand Down Expand Up @@ -52,6 +57,11 @@ export function createWebViewObjects() {
name: 'a',
target: 'b',
getWebView: mockGetWebViewA,
// For one of the streams, we test that a custom btoa function is used.
btoa: (data: string) => {
const bytes = stringToBytes(data);
return bytesToBase64(bytes);
},
});

const streamB = new WebViewMessageStream({
Expand Down

0 comments on commit ae074db

Please sign in to comment.