-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add onInstall and onUpdate to snaps-jest
- Loading branch information
Showing
11 changed files
with
237 additions
and
29 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
13 changes: 0 additions & 13 deletions
13
packages/examples/packages/lifecycle-hooks/src/index.test.ts
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/examples/packages/lifecycle-hooks/src/index.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,41 @@ | ||
import { describe, it } from '@jest/globals'; | ||
import { installSnap } from '@metamask/snaps-jest'; | ||
import { Box, Text } from '@metamask/snaps-sdk/jsx'; | ||
|
||
describe('onInstall', () => { | ||
it('shows dialog when the snap is installed', async () => { | ||
const { onInstall } = await installSnap(); | ||
|
||
const response = await onInstall(); | ||
|
||
const screen = response.getInterface(); | ||
|
||
expect(screen).toRender( | ||
<Box> | ||
<Text> | ||
The Snap was installed successfully, and the "onInstall" handler was | ||
called. | ||
</Text> | ||
</Box>, | ||
); | ||
}); | ||
}); | ||
|
||
describe('onUpdate', () => { | ||
it('shows dialog when the snap is updated', async () => { | ||
const { onUpdate } = await installSnap(); | ||
|
||
const response = await onUpdate(); | ||
|
||
const screen = response.getInterface(); | ||
|
||
expect(screen).toRender( | ||
<Box> | ||
<Text> | ||
The Snap was updated successfully, and the "onUpdate" handler was | ||
called. | ||
</Text> | ||
</Box>, | ||
); | ||
}); | ||
}); |
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
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