From 17e08380f5be6d58f3f7d3736d64ce98fffd8015 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 28 Mar 2017 10:35:56 -0700 Subject: [PATCH] Update JSX to not enclose prop arguments in whitespace. Update tests to expect kuiButton__inner. --- .../button/__snapshots__/button.test.js.snap | 48 ++++++++++++++----- .../__snapshots__/link_button.test.js.snap | 48 ++++++++++++++----- ui_framework/components/button/button.js | 6 +-- ui_framework/components/button/button.test.js | 2 +- .../components/button/link_button.test.js | 48 +++---------------- .../components/button/submit_button.test.js | 48 +++---------------- 6 files changed, 90 insertions(+), 110 deletions(-) diff --git a/ui_framework/components/button/__snapshots__/button.test.js.snap b/ui_framework/components/button/__snapshots__/button.test.js.snap index abc1fb8bb6198..979451ac42be7 100644 --- a/ui_framework/components/button/__snapshots__/button.test.js.snap +++ b/ui_framework/components/button/__snapshots__/button.test.js.snap @@ -7,7 +7,9 @@ exports[`KuiButton Baseline HTML attributes are rendered 1`] = ` data-test-subj="test subject string" disabled="" > - + `; @@ -15,7 +17,9 @@ exports[`KuiButton Baseline is rendered 1`] = ` `; @@ -23,7 +27,9 @@ exports[`KuiButton Props children is rendered 1`] = ` @@ -58,7 +68,9 @@ exports[`KuiButton Props iconPosition moves the icon to the right 1`] = ` `; @@ -105,7 +123,9 @@ exports[`KuiButton Props type danger renders the danger class 1`] = ` `; @@ -113,7 +133,9 @@ exports[`KuiButton Props type hollow renders the hollow class 1`] = ` `; @@ -121,6 +143,8 @@ exports[`KuiButton Props type primary renders the primary class 1`] = ` `; diff --git a/ui_framework/components/button/__snapshots__/link_button.test.js.snap b/ui_framework/components/button/__snapshots__/link_button.test.js.snap index 92e4dda672387..8c897a6f25220 100644 --- a/ui_framework/components/button/__snapshots__/link_button.test.js.snap +++ b/ui_framework/components/button/__snapshots__/link_button.test.js.snap @@ -8,7 +8,9 @@ exports[`KuiLinkButton Baseline HTML attributes are rendered (and disabled rende href="#" target="_blank" > - + `; @@ -16,7 +18,9 @@ exports[`KuiLinkButton Baseline is rendered 1`] = ` - + `; @@ -24,7 +28,9 @@ exports[`KuiLinkButton Props children is rendered 1`] = ` - + Hello @@ -36,7 +42,9 @@ exports[`KuiLinkButton Props icon is rendered with children 1`] = ` - + Icon Hello @@ -49,7 +57,9 @@ exports[`KuiLinkButton Props icon is rendered without children 1`] = ` - + Icon @@ -59,7 +69,9 @@ exports[`KuiLinkButton Props iconPosition moves the icon to the right 1`] = ` - + Hello @@ -72,7 +84,9 @@ exports[`KuiLinkButton Props isLoading doesn't render the icon prop 1`] = ` - + `; @@ -106,7 +124,9 @@ exports[`KuiLinkButton Props type danger renders the danger class 1`] = ` - + `; @@ -114,7 +134,9 @@ exports[`KuiLinkButton Props type hollow renders the hollow class 1`] = ` - + `; @@ -122,6 +144,8 @@ exports[`KuiLinkButton Props type primary renders the primary class 1`] = ` - + `; diff --git a/ui_framework/components/button/button.js b/ui_framework/components/button/button.js index 3adeffc4d9940..32868f2c137a1 100644 --- a/ui_framework/components/button/button.js +++ b/ui_framework/components/button/button.js @@ -75,7 +75,7 @@ const KuiButton = ({ type, hasIcon: icon || isLoading, })} - { ...rest } + {...rest} > {children} @@ -157,7 +157,7 @@ const KuiSubmitButton = ({ type="submit" value={children} className={getClassName({ className, type })} - { ...rest } + {...rest} /> ); }; diff --git a/ui_framework/components/button/button.test.js b/ui_framework/components/button/button.test.js index a5458777015e1..85edd8c2ef151 100644 --- a/ui_framework/components/button/button.test.js +++ b/ui_framework/components/button/button.test.js @@ -38,7 +38,7 @@ describe('KuiButton', () => { BUTTON_TYPES.forEach(type => { describe(type, () => { test(`renders the ${type} class`, () => { - const $button = render(); + const $button = render(); expect($button).toMatchSnapshot(); }); }); diff --git a/ui_framework/components/button/link_button.test.js b/ui_framework/components/button/link_button.test.js index fb9dcdb260e0b..7cccc1ab099fb 100644 --- a/ui_framework/components/button/link_button.test.js +++ b/ui_framework/components/button/link_button.test.js @@ -2,6 +2,7 @@ import React from 'react'; import { render } from 'enzyme'; import { + BUTTON_TYPES, KuiLinkButton, } from './button'; @@ -35,47 +36,12 @@ describe('KuiLinkButton', () => { describe('Props', () => { describe('type', () => { - describe('basic', () => { - test('renders the basic class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('hollow', () => { - test('renders the hollow class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('danger', () => { - test('renders the danger class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('primary', () => { - test('renders the primary class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); + BUTTON_TYPES.forEach(type => { + describe(type, () => { + test(`renders the ${type} class`, () => { + const $button = render(); + expect($button).toMatchSnapshot(); + }); }); }); }); diff --git a/ui_framework/components/button/submit_button.test.js b/ui_framework/components/button/submit_button.test.js index 81b74cc4ced30..62462d5154ff7 100644 --- a/ui_framework/components/button/submit_button.test.js +++ b/ui_framework/components/button/submit_button.test.js @@ -3,6 +3,7 @@ import { render, shallow } from 'enzyme'; import sinon from 'sinon'; import { + BUTTON_TYPES, KuiSubmitButton, } from './button'; @@ -34,47 +35,12 @@ describe('KuiSubmitButton', () => { describe('Props', () => { describe('type', () => { - describe('basic', () => { - test('renders the basic class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('hollow', () => { - test('renders the hollow class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('danger', () => { - test('renders the danger class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('primary', () => { - test('renders the primary class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); + BUTTON_TYPES.forEach(type => { + describe(type, () => { + test(`renders the ${type} class`, () => { + const $button = render(); + expect($button).toMatchSnapshot(); + }); }); }); });