-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing an empty array of messages to VerificationMessages (#216)
* Allow passing an empty array of messages to VerificationMessages * Update src/shared-components/verificationMessages/test.js Co-Authored-By: Diego Fortes <[email protected]> Co-authored-by: Diego Fortes <[email protected]>
- Loading branch information
1 parent
674ba85
commit cb56dd1
Showing
3 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/shared-components/verificationMessages/__snapshots__/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,78 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<VerificationMessages /> UI snapshot renders content and children 1`] = ` | ||
.emotion-6 { | ||
list-style-type: none; | ||
margin: 0; | ||
} | ||
.emotion-0 { | ||
color: #706D87; | ||
font-size: 0.875rem; | ||
line-height: 1.71; | ||
color: #BD200F; | ||
line-height: 24px; | ||
} | ||
.emotion-0:last-of-type { | ||
margin: 0 0 0.125rem 0; | ||
} | ||
<ul | ||
className="emotion-6 emotion-7" | ||
> | ||
<li | ||
className="emotion-0 emotion-1" | ||
style={ | ||
Object { | ||
"maxHeight": "48px", | ||
"opacity": "1", | ||
"transitionDuration": "350ms", | ||
"transitionProperty": "max-height, opacity", | ||
"transitionTimingFunction": "ease-in-out", | ||
} | ||
} | ||
type="error" | ||
> | ||
<strong> | ||
Uh oh! | ||
</strong> | ||
This field is required | ||
</li> | ||
<li | ||
className="emotion-0 emotion-1" | ||
style={ | ||
Object { | ||
"maxHeight": "48px", | ||
"opacity": "1", | ||
"transitionDuration": "350ms", | ||
"transitionProperty": "max-height, opacity", | ||
"transitionTimingFunction": "ease-in-out", | ||
} | ||
} | ||
type="error" | ||
> | ||
<strong> | ||
Uh oh! | ||
</strong> | ||
Must be at least 3 characters | ||
</li> | ||
<li | ||
className="emotion-0 emotion-1" | ||
style={ | ||
Object { | ||
"maxHeight": "48px", | ||
"opacity": "1", | ||
"transitionDuration": "350ms", | ||
"transitionProperty": "max-height, opacity", | ||
"transitionTimingFunction": "ease-in-out", | ||
} | ||
} | ||
type="error" | ||
> | ||
Must contain 1 number | ||
, | ||
Must contain 1 symbol | ||
</li> | ||
</ul> | ||
`; |
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,41 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import VerificationMessages from './index'; | ||
|
||
describe('<VerificationMessages />', () => { | ||
describe('UI snapshot', () => { | ||
it('renders content and children', () => { | ||
const messages = { | ||
required: ( | ||
<React.Fragment> | ||
<strong>Uh oh!</strong> This field is required | ||
</React.Fragment> | ||
), | ||
maxLength: ( | ||
<React.Fragment> | ||
<strong>Uh oh!</strong> Must be at least 3 characters | ||
</React.Fragment> | ||
), | ||
charactersRequired: ['Must contain 1 number', 'Must contain 1 symbol'], | ||
}; | ||
const component = renderer.create( | ||
<VerificationMessages messages={messages} />, | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('when message value is an empty array', () => { | ||
it('renders nothing', () => { | ||
const messages = { | ||
required: [], | ||
}; | ||
const wrapper = shallow(<VerificationMessages messages={messages} />); | ||
expect(wrapper.html().indexOf('li') === -1).toBe(true); | ||
}); | ||
}); | ||
}); |