-
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.
Continue converting tests from enzyme to @testing-library/react (#16373)
* Add transaction activity log component * Remove duplicate tx activity log snapshot. * Convert Identicon test to tlr. * Convert Metafoxlogo test to tlr. * Convert Reveal Seed Phrase test to tlr. * Consolidate and convert Send Footer test to tlr. * Convert Settings test to tlr. * Consolidate and convert security tab test to tlr. * Convert null selectedOption to empty string, and add test id to Dropdown component. * Add Send state to mock-state * Lint mock-state.json
- Loading branch information
Showing
19 changed files
with
908 additions
and
506 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
70 changes: 70 additions & 0 deletions
70
ui/components/ui/identicon/__snapshots__/identicon.component.test.js.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,70 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Identicon should match snapshot with address prop div 1`] = ` | ||
<div> | ||
<div | ||
class="" | ||
> | ||
<div | ||
class="identicon test-address" | ||
style="height: 46px; width: 46px; border-radius: 23px;" | ||
> | ||
<div | ||
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 46px; height: 46px; display: inline-block; background: rgb(24, 151, 242);" | ||
> | ||
<svg | ||
height="46" | ||
width="46" | ||
x="0" | ||
y="0" | ||
> | ||
<rect | ||
fill="#2362E1" | ||
height="46" | ||
transform="translate(5.159662140639244 -7.668071520898189) rotate(458.4 23 23)" | ||
width="46" | ||
x="0" | ||
y="0" | ||
/> | ||
<rect | ||
fill="#F94301" | ||
height="46" | ||
transform="translate(-22.084972728872177 11.489005476012034) rotate(268.8 23 23)" | ||
width="46" | ||
x="0" | ||
y="0" | ||
/> | ||
<rect | ||
fill="#FA7900" | ||
height="46" | ||
transform="translate(-13.047115238995795 42.377522828482356) rotate(117.3 23 23)" | ||
width="46" | ||
x="0" | ||
y="0" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Identicon should match snapshot with custom image and className props 1`] = ` | ||
<div> | ||
<img | ||
alt="" | ||
class="identicon test-image" | ||
src="test-image" | ||
style="height: 46px; width: 46px; border-radius: 23px;" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Identicon should match snapshot with default props 1`] = ` | ||
<div> | ||
<div | ||
class="identicon__image-border" | ||
style="height: 46px; width: 46px; border-radius: 23px;" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,51 @@ | ||
import React from 'react'; | ||
import thunk from 'redux-thunk'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import { mount } from 'enzyme'; | ||
import Identicon from './identicon.component'; | ||
import { renderWithProvider } from '../../../../test/lib/render-helpers'; | ||
import Identicon from '.'; | ||
|
||
describe('Identicon', () => { | ||
const state = { | ||
const mockState = { | ||
metamask: { | ||
provider: { | ||
chainId: '0x99', | ||
}, | ||
useBlockie: false, | ||
}, | ||
}; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
const store = mockStore(state); | ||
const mockStore = configureMockStore()(mockState); | ||
|
||
it('renders empty identicon with no props', () => { | ||
const wrapper = mount(<Identicon store={store} />); | ||
it('should match snapshot with default props', () => { | ||
const { container } = renderWithProvider(<Identicon />, mockStore); | ||
|
||
expect(wrapper.find('div').prop('className')).toStrictEqual( | ||
'identicon__image-border', | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders custom image and add className props', () => { | ||
const wrapper = mount( | ||
<Identicon store={store} className="test-image" image="test-image" />, | ||
); | ||
it('should match snapshot with custom image and className props', () => { | ||
const props = { | ||
className: 'test-image', | ||
image: 'test-image', | ||
}; | ||
|
||
expect(wrapper.find('img.test-image').prop('className')).toStrictEqual( | ||
'identicon test-image', | ||
); | ||
expect(wrapper.find('img.test-image').prop('src')).toStrictEqual( | ||
'test-image', | ||
const { container } = renderWithProvider( | ||
<Identicon {...props} />, | ||
mockStore, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders div with address prop', () => { | ||
const wrapper = mount( | ||
<Identicon | ||
store={store} | ||
className="test-address" | ||
address="0x0000000000000000000000000000000000000000" | ||
/>, | ||
); | ||
it('should match snapshot with address prop div', () => { | ||
const props = { | ||
className: 'test-address', | ||
address: '0x0000000000000000000000000000000000000000', | ||
}; | ||
|
||
expect(wrapper.find('div.test-address').prop('className')).toStrictEqual( | ||
'identicon test-address', | ||
const { container } = renderWithProvider( | ||
<Identicon {...props} />, | ||
mockStore, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
ui/components/ui/metafox-logo/__snapshots__/metafox-logo.component.test.js.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,35 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MetaFoxLogo does not set icon height and width when unsetIconHeight is true 1`] = ` | ||
<div> | ||
<div | ||
class="app-header__logo-container" | ||
data-testid="app-header-logo" | ||
> | ||
<div /> | ||
<img | ||
alt="" | ||
class="app-header__metafox-logo--icon" | ||
src="./images/logo/metamask-fox.svg" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`MetaFoxLogo should match snapshot with img width and height default set to 42 1`] = ` | ||
<div> | ||
<div | ||
class="app-header__logo-container" | ||
data-testid="app-header-logo" | ||
> | ||
<div /> | ||
<img | ||
alt="" | ||
class="app-header__metafox-logo--icon" | ||
height="42" | ||
src="./images/logo/metamask-fox.svg" | ||
width="42" | ||
/> | ||
</div> | ||
</div> | ||
`; |
27 changes: 11 additions & 16 deletions
27
ui/components/ui/metafox-logo/metafox-logo.component.test.js
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,27 +1,22 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { renderWithProvider } from '../../../../test/lib/render-helpers'; | ||
import MetaFoxLogo from '.'; | ||
|
||
// eslint-disable-next-line react/display-name | ||
jest.mock('./horizontal-logo.js', () => () => { | ||
return <div></div>; | ||
}); | ||
|
||
describe('MetaFoxLogo', () => { | ||
it('sets icon height and width to 42 by default', () => { | ||
const wrapper = mount(<MetaFoxLogo />); | ||
it('should match snapshot with img width and height default set to 42', () => { | ||
const { container } = renderWithProvider(<MetaFoxLogo />); | ||
|
||
expect( | ||
wrapper.find('img.app-header__metafox-logo--icon').prop('width'), | ||
).toStrictEqual(42); | ||
expect( | ||
wrapper.find('img.app-header__metafox-logo--icon').prop('height'), | ||
).toStrictEqual(42); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('does not set icon height and width when unsetIconHeight is true', () => { | ||
const wrapper = mount(<MetaFoxLogo unsetIconHeight />); | ||
const { container } = renderWithProvider(<MetaFoxLogo unsetIconHeight />); | ||
|
||
expect( | ||
wrapper.find('img.app-header__metafox-logo--icon').prop('width'), | ||
).toBeUndefined(); | ||
expect( | ||
wrapper.find('img.app-header__metafox-logo--icon').prop('height'), | ||
).toBeUndefined(); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.