-
Notifications
You must be signed in to change notification settings - Fork 557
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
f92ab41
commit 727f8a0
Showing
6 changed files
with
134 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { mergeValue } from './utils'; | ||
|
||
describe('mergeValue', () => { | ||
it('merges a value outside of a form', () => { | ||
const state = { foo: 'bar' }; | ||
|
||
const result = mergeValue(state, 'foo', 'baz'); | ||
|
||
expect(result).toStrictEqual({ foo: 'baz' }); | ||
}); | ||
|
||
it('merges a value inside of a form', () => { | ||
const state = { foo: { bar: 'baz' } }; | ||
|
||
const result = mergeValue(state, 'bar', 'test', 'foo'); | ||
|
||
expect(result).toStrictEqual({ foo: { bar: 'test' } }); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Bold, Text } from '@metamask/snaps-sdk/jsx'; | ||
import { getJsxChildren } from '@metamask/snaps-utils'; | ||
|
||
import { SnapComponent } from '../features/renderer'; | ||
import { renderTextChildren } from './render'; | ||
|
||
describe('renderTextChildren', () => { | ||
it('returns a sting child', () => { | ||
const element = Text({ children: 'Hello, world!' }); | ||
|
||
const result = renderTextChildren(getJsxChildren(element), 'test'); | ||
|
||
expect(result).toStrictEqual(['Hello, world!']); | ||
}); | ||
|
||
it('returns a JSX child', () => { | ||
const element = Text({ children: Bold({ children: 'Hello world' }) }); | ||
|
||
const result = renderTextChildren(getJsxChildren(element), 'test'); | ||
|
||
expect(result).toStrictEqual([ | ||
<SnapComponent | ||
key={`test-text-child-0`} | ||
id={`test-text-child-0`} | ||
node={Bold({ children: 'Hello world' })} | ||
/>, | ||
]); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"branches": 96.56, | ||
"functions": 98.4, | ||
"lines": 98.52, | ||
"statements": 94.71 | ||
"branches": 96.82, | ||
"functions": 98.8, | ||
"lines": 98.87, | ||
"statements": 95.02 | ||
} |
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