-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56607d6
commit cfead75
Showing
8 changed files
with
273 additions
and
21 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
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
1 change: 0 additions & 1 deletion
1
ui/pages/confirmations/components/confirm/snaps/snaps-insight/index.ts
This file was deleted.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
...rmations/components/confirm/snaps/snaps-section/__snapshots__/snaps-section.test.tsx.snap
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,115 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SnapsSection renders section for typed sign request 1`] = ` | ||
<div> | ||
<div | ||
class="mm-box mm-box--margin-bottom-4 mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-column" | ||
> | ||
<div | ||
class="mm-box delineator__wrapper mm-box--display-flex mm-box--flex-direction-column mm-box--background-color-background-default mm-box--rounded-lg" | ||
> | ||
<div | ||
class="mm-box delineator__header delineator__header--expanded mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-0 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-space-between mm-box--align-items-center" | ||
> | ||
<div | ||
class="mm-box mm-box--display-flex mm-box--align-items-center" | ||
> | ||
<p | ||
class="mm-box mm-text mm-text--body-md mm-box--color-text-default" | ||
> | ||
<span> | ||
Insights from | ||
<span | ||
class="mm-box mm-text mm-text--inherit mm-text--font-weight-medium mm-box--color-inherit" | ||
> | ||
BIP-32 Test Snap | ||
</span> | ||
</span> | ||
</p> | ||
</div> | ||
<span | ||
class="mm-box mm-icon mm-icon--size-sm mm-box--display-inline-block mm-box--color-primary-default" | ||
style="mask-image: url('./images/icons/arrow-up.svg');" | ||
/> | ||
</div> | ||
<div | ||
class="mm-box mm-box--padding-top-0 mm-box--padding-right-0 mm-box--padding-bottom-0 mm-box--padding-left-0 mm-box--flex-direction-column" | ||
> | ||
<div | ||
class="mm-box snap-ui-renderer__content mm-box--height-full" | ||
> | ||
<div | ||
class="box snap-ui-renderer__container box--display-flex box--flex-direction-column box--height-full" | ||
> | ||
<p | ||
class="mm-box mm-text snap-ui-renderer__text mm-text--body-md mm-text--overflow-wrap-anywhere mm-box--color-inherit" | ||
> | ||
Hello world again! | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`SnapsSection renders section personal sign request 1`] = ` | ||
<div> | ||
<div | ||
class="mm-box mm-box--margin-bottom-4 mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-column" | ||
> | ||
<div | ||
class="mm-box delineator__wrapper mm-box--display-flex mm-box--flex-direction-column mm-box--background-color-background-default mm-box--rounded-lg" | ||
> | ||
<div | ||
class="mm-box delineator__header delineator__header--expanded mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-0 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-space-between mm-box--align-items-center" | ||
> | ||
<div | ||
class="mm-box mm-box--display-flex mm-box--align-items-center" | ||
> | ||
<p | ||
class="mm-box mm-text mm-text--body-md mm-box--color-text-default" | ||
> | ||
<span> | ||
Insights from | ||
<span | ||
class="mm-box mm-text mm-text--inherit mm-text--font-weight-medium mm-box--color-inherit" | ||
> | ||
BIP-32 Test Snap | ||
</span> | ||
</span> | ||
</p> | ||
</div> | ||
<span | ||
class="mm-box mm-icon mm-icon--size-sm mm-box--display-inline-block mm-box--color-primary-default" | ||
style="mask-image: url('./images/icons/arrow-up.svg');" | ||
/> | ||
</div> | ||
<div | ||
class="mm-box mm-box--padding-top-0 mm-box--padding-right-0 mm-box--padding-bottom-0 mm-box--padding-left-0 mm-box--flex-direction-column" | ||
> | ||
<div | ||
class="mm-box snap-ui-renderer__content mm-box--height-full" | ||
> | ||
<div | ||
class="box snap-ui-renderer__container box--display-flex box--flex-direction-column box--height-full" | ||
> | ||
<p | ||
class="mm-box mm-text snap-ui-renderer__text mm-text--body-md mm-text--overflow-wrap-anywhere mm-box--color-inherit" | ||
> | ||
Hello world! | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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
91 changes: 91 additions & 0 deletions
91
ui/pages/confirmations/components/confirm/snaps/snaps-section/snaps-section.test.tsx
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,91 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import { Text } from '@metamask/snaps-sdk/jsx'; | ||
|
||
import mockState from '../../../../../../../test/data/mock-state.json'; | ||
import { unapprovedPersonalSignMsg } from '../../../../../../../test/data/confirmations/personal_sign'; | ||
import { unapprovedTypedSignMsgV3 } from '../../../../../../../test/data/confirmations/typed_sign'; | ||
import { renderWithProvider } from '../../../../../../../test/lib/render-helpers'; | ||
import { fireEvent } from '@testing-library/react'; | ||
import { SnapsSection } from './snaps-section'; | ||
|
||
const additionalMockState = { | ||
insights: { | ||
[unapprovedPersonalSignMsg.id]: { | ||
'npm:@metamask/test-snap-bip32': { | ||
snapId: 'npm:@metamask/test-snap-bip32', | ||
loading: false, | ||
interfaceId: 'interface-id', | ||
}, | ||
}, | ||
[unapprovedTypedSignMsgV3.id]: { | ||
'npm:@metamask/test-snap-bip32': { | ||
snapId: 'npm:@metamask/test-snap-bip32', | ||
loading: false, | ||
interfaceId: 'interface-id2', | ||
}, | ||
}, | ||
}, | ||
interfaces: { | ||
'interface-id': { | ||
snapId: 'npm:@metamask/test-snap-bip32', | ||
content: Text({ children: 'Hello world!' }), | ||
state: {}, | ||
context: null, | ||
}, | ||
'interface-id2': { | ||
snapId: 'npm:@metamask/test-snap-bip32', | ||
content: Text({ children: 'Hello world again!' }), | ||
state: {}, | ||
context: null, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('SnapsSection', () => { | ||
it('renders section personal sign request', () => { | ||
const state = { | ||
...mockState, | ||
confirm: { | ||
currentConfirmation: unapprovedPersonalSignMsg, | ||
}, | ||
metamask: { | ||
...mockState.metamask, | ||
...additionalMockState, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(state); | ||
const { container, getByText } = renderWithProvider( | ||
<SnapsSection />, | ||
mockStore, | ||
); | ||
|
||
fireEvent.click(getByText('Insights from')); | ||
|
||
expect(container).toMatchSnapshot(); | ||
expect(getByText('Hello world!')).toBeDefined(); | ||
}); | ||
|
||
it('renders section for typed sign request', () => { | ||
const state = { | ||
...mockState, | ||
confirm: { | ||
currentConfirmation: unapprovedTypedSignMsgV3, | ||
}, | ||
metamask: { | ||
...mockState.metamask, | ||
...additionalMockState, | ||
}, | ||
}; | ||
const mockStore = configureMockStore([])(state); | ||
const { container, getByText } = renderWithProvider( | ||
<SnapsSection />, | ||
mockStore, | ||
); | ||
|
||
fireEvent.click(getByText('Insights from')); | ||
|
||
expect(container).toMatchSnapshot(); | ||
expect(getByText('Hello world again!')).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.