Skip to content

Commit

Permalink
clean up the message component in magic field gorup #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Jul 7, 2018
1 parent 53c3522 commit 410d17b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/components/fields/magic-select/MagicFieldGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ export class MagicFieldGroup extends React.PureComponent {
id={this.props.id}
label={this.props.label}
/>

<Message
message={this.props.message}
/>
{this.props.message.message &&
<Message
message={this.props.message}
/>
}
{this.state.isOpen &&
<ButtonGroup
onChange={this.onChangeListType}
Expand Down
29 changes: 28 additions & 1 deletion src/components/fields/magic-select/MagicFieldGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const genericChangeHandler = () => {
describe('MagicFieldGroup component', () => {


it( 'matches snapshot', () => {
it( 'matches snapshot with no message', () => {
const component = renderer.create(
<MagicFieldGroup
id={'magic-3'}
Expand All @@ -35,6 +35,33 @@ describe('MagicFieldGroup component', () => {
expect(component.toJSON() ).toMatchSnapshot();
});

it( 'matches snapshot with message', () => {
const component = renderer.create(
<MagicFieldGroup
id={'magic-3'}
label={'Hi Roy'}
fieldClassName={'magic'}
onValueChange={genericChangeHandler}
options={[
{
label: 'HTML',
value: 'html'
},
{
label: 'Plain Text',
value: 'plain'
}
]}
isOpen={false}
message={{
message: 'Hi Roy',
error: false,
}}
/>
);
expect(component.toJSON() ).toMatchSnapshot();
});

describe( 'Inner input', () => {
it('Has inner input', () => {
const component = mount(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MagicFieldGroup component matches snapshot 1`] = `
exports[`MagicFieldGroup component matches snapshot with message 1`] = `
<div
className="caldera-magic-select-group caldera-config-field"
>
Expand All @@ -9,6 +9,46 @@ exports[`MagicFieldGroup component matches snapshot 1`] = `
>
Hi Roy
</label>
<div
className="caldera-components-message caldera-components-not-error"
>
Hi Roy
</div>
<div
style={
Object {
"display": "inline-block",
}
}
>
<input
aria-autocomplete="list"
aria-expanded={false}
autoComplete="off"
className="caldera-magic-input caldera-magic-input-magic-3 magic"
id="magic-3"
onBlur={[Function]}
onChange={[Function]}
onClick={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
role="combobox"
value=""
/>
</div>
</div>
`;

exports[`MagicFieldGroup component matches snapshot with no message 1`] = `
<div
className="caldera-magic-select-group caldera-config-field"
>
<label
htmlFor="magic-3"
>
Hi Roy
</label>
<div
style={
Object {
Expand Down

0 comments on commit 410d17b

Please sign in to comment.