Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const config = createConfig([
},
},
{
files: ['**/*.ts'],
files: ['**/*.{ts,tsx}'],
extends: [typescript],
languageOptions: {
parserOptions: {
Expand Down Expand Up @@ -168,7 +168,7 @@ const config = createConfig([
},
},
{
files: ['**/*.test.{js,ts}', '**/tests/**/*.{js,ts}'],
files: ['**/*.test.{js,ts,tsx}', '**/tests/**/*.{js,ts,tsx}'],
extends: [jest],
rules: {
// TODO: Upgrade these from warning to error in shared config
Expand Down
23 changes: 12 additions & 11 deletions packages/sample-snap/src/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { expect } from '@jest/globals';
import type { SnapConfirmationInterface } from '@metamask/snaps-jest';
import { installSnap } from '@metamask/snaps-jest';
import { Box, Text, Bold } from '@metamask/snaps-sdk/jsx';
import { Box, Text as SnapText, Bold } from '@metamask/snaps-sdk/jsx';
Comment thread
mikesposito marked this conversation as resolved.

describe('onRpcRequest', () => {
describe('hello', () => {
it('shows a confirmation dialog', async () => {
const { request } = await installSnap();
const snap = await installSnap();

const origin = 'Jest';
const response = request({
const response = snap.request({
method: 'hello',
origin,
});
Expand All @@ -18,14 +17,16 @@ describe('onRpcRequest', () => {
expect(ui.type).toBe('confirmation');
expect(ui).toRender(
<Box>
<Text>
<SnapText>
Hello, <Bold>{origin}</Bold>!
</Text>
<Text>This custom confirmation is just for display purposes.</Text>
<Text>
</SnapText>
<SnapText>
This custom confirmation is just for display purposes.
</SnapText>
<SnapText>
But you can edit the snap source code to make it do something, if
you want to!
</Text>
</SnapText>
</Box>,
);

Expand All @@ -36,9 +37,9 @@ describe('onRpcRequest', () => {
});

it('throws an error if the requested method does not exist', async () => {
const { request } = await installSnap();
const snap = await installSnap();

const response = await request({
const response = await snap.request({
method: 'foo',
});

Expand Down
14 changes: 7 additions & 7 deletions packages/sample-snap/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { OnRpcRequestHandler } from '@metamask/snaps-sdk';
import { Box, Text, Bold } from '@metamask/snaps-sdk/jsx';
import { Box, Text as SnapText, Bold } from '@metamask/snaps-sdk/jsx';

/**
* Handle incoming JSON-RPC requests, sent through `wallet_invokeSnap`.
Expand All @@ -23,16 +23,16 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
type: 'confirmation',
content: (
<Box>
<Text>
<SnapText>
Hello, <Bold>{origin}</Bold>!
</Text>
<Text>
</SnapText>
<SnapText>
This custom confirmation is just for display purposes.
</Text>
<Text>
</SnapText>
<SnapText>
But you can edit the snap source code to make it do something,
if you want to!
</Text>
</SnapText>
</Box>
),
},
Expand Down
3 changes: 2 additions & 1 deletion packages/sample-snap/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk"
"jsxImportSource": "@metamask/snaps-sdk",
"types": ["jest"]
},
"include": ["**/*.ts", "**/*.tsx"]
}
Loading