Skip to content

Commit

Permalink
Update JSX to not enclose prop arguments in whitespace. Update tests …
Browse files Browse the repository at this point in the history
…to expect kuiButton__inner.
  • Loading branch information
cjcenizal committed Mar 28, 2017
1 parent c28bbd7 commit 17e0838
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 110 deletions.
48 changes: 36 additions & 12 deletions ui_framework/components/button/__snapshots__/button.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ exports[`KuiButton Baseline HTML attributes are rendered 1`] = `
data-test-subj="test subject string"
disabled=""
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;

exports[`KuiButton Baseline is rendered 1`] = `
<button
class="kuiButton"
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;

exports[`KuiButton Props children is rendered 1`] = `
<button
class="kuiButton"
>
<span>
<span
class="kuiButton__inner"
>
<span>
Hello
</span>
Expand All @@ -35,7 +41,9 @@ exports[`KuiButton Props icon is rendered with children 1`] = `
<button
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
Icon
<span>
Hello
Expand All @@ -48,7 +56,9 @@ exports[`KuiButton Props icon is rendered without children 1`] = `
<button
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
Icon
</span>
</button>
Expand All @@ -58,7 +68,9 @@ exports[`KuiButton Props iconPosition moves the icon to the right 1`] = `
<button
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span>
Hello
</span>
Expand All @@ -71,7 +83,9 @@ exports[`KuiButton Props isLoading doesn't render the icon prop 1`] = `
<button
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span
aria-hidden="true"
class="kuiButton__icon kuiIcon fa-spinner fa-spin"
Expand All @@ -84,7 +98,9 @@ exports[`KuiButton Props isLoading renders a spinner 1`] = `
<button
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span
aria-hidden="true"
class="kuiButton__icon kuiIcon fa-spinner fa-spin"
Expand All @@ -97,30 +113,38 @@ exports[`KuiButton Props type basic renders the basic class 1`] = `
<button
class="kuiButton kuiButton--basic"
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;

exports[`KuiButton Props type danger renders the danger class 1`] = `
<button
class="kuiButton kuiButton--danger"
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;

exports[`KuiButton Props type hollow renders the hollow class 1`] = `
<button
class="kuiButton kuiButton--hollow"
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;

exports[`KuiButton Props type primary renders the primary class 1`] = `
<button
class="kuiButton kuiButton--primary"
>
<span />
<span
class="kuiButton__inner"
/>
</button>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ exports[`KuiLinkButton Baseline HTML attributes are rendered (and disabled rende
href="#"
target="_blank"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;

exports[`KuiLinkButton Baseline is rendered 1`] = `
<a
class="kuiButton"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;

exports[`KuiLinkButton Props children is rendered 1`] = `
<a
class="kuiButton"
>
<span>
<span
class="kuiButton__inner"
>
<span>
Hello
</span>
Expand All @@ -36,7 +42,9 @@ exports[`KuiLinkButton Props icon is rendered with children 1`] = `
<a
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
Icon
<span>
Hello
Expand All @@ -49,7 +57,9 @@ exports[`KuiLinkButton Props icon is rendered without children 1`] = `
<a
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
Icon
</span>
</a>
Expand All @@ -59,7 +69,9 @@ exports[`KuiLinkButton Props iconPosition moves the icon to the right 1`] = `
<a
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span>
Hello
</span>
Expand All @@ -72,7 +84,9 @@ exports[`KuiLinkButton Props isLoading doesn't render the icon prop 1`] = `
<a
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span
aria-hidden="true"
class="kuiButton__icon kuiIcon fa-spinner fa-spin"
Expand All @@ -85,7 +99,9 @@ exports[`KuiLinkButton Props isLoading renders a spinner 1`] = `
<a
class="kuiButton kuiButton--iconText"
>
<span>
<span
class="kuiButton__inner"
>
<span
aria-hidden="true"
class="kuiButton__icon kuiIcon fa-spinner fa-spin"
Expand All @@ -98,30 +114,38 @@ exports[`KuiLinkButton Props type basic renders the basic class 1`] = `
<a
class="kuiButton kuiButton--basic"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;

exports[`KuiLinkButton Props type danger renders the danger class 1`] = `
<a
class="kuiButton kuiButton--danger"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;

exports[`KuiLinkButton Props type hollow renders the hollow class 1`] = `
<a
class="kuiButton kuiButton--hollow"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;

exports[`KuiLinkButton Props type primary renders the primary class 1`] = `
<a
class="kuiButton kuiButton--primary"
>
<span />
<span
class="kuiButton__inner"
/>
</a>
`;
6 changes: 3 additions & 3 deletions ui_framework/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const KuiButton = ({
type,
hasIcon: icon || isLoading,
})}
{ ...rest }
{...rest}
>
<ContentWithIcon
icon={icon}
Expand Down Expand Up @@ -128,7 +128,7 @@ const KuiLinkButton = ({
<ContentWithIcon
icon={icon}
iconPosition={iconPosition}
isLoading={ isLoading }
isLoading={isLoading}
>
{children}
</ContentWithIcon>
Expand Down Expand Up @@ -157,7 +157,7 @@ const KuiSubmitButton = ({
type="submit"
value={children}
className={getClassName({ className, type })}
{ ...rest }
{...rest}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion ui_framework/components/button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('KuiButton', () => {
BUTTON_TYPES.forEach(type => {
describe(type, () => {
test(`renders the ${type} class`, () => {
const $button = render(<KuiButton type={ type } />);
const $button = render(<KuiButton type={type} />);
expect($button).toMatchSnapshot();
});
});
Expand Down
48 changes: 7 additions & 41 deletions ui_framework/components/button/link_button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { render } from 'enzyme';

import {
BUTTON_TYPES,
KuiLinkButton,
} from './button';

Expand Down Expand Up @@ -35,47 +36,12 @@ describe('KuiLinkButton', () => {

describe('Props', () => {
describe('type', () => {
describe('basic', () => {
test('renders the basic class', () => {
const $button = render(
<KuiLinkButton type="basic" />
);

expect($button)
.toMatchSnapshot();
});
});

describe('hollow', () => {
test('renders the hollow class', () => {
const $button = render(
<KuiLinkButton type="hollow" />
);

expect($button)
.toMatchSnapshot();
});
});

describe('danger', () => {
test('renders the danger class', () => {
const $button = render(
<KuiLinkButton type="danger" />
);

expect($button)
.toMatchSnapshot();
});
});

describe('primary', () => {
test('renders the primary class', () => {
const $button = render(
<KuiLinkButton type="primary" />
);

expect($button)
.toMatchSnapshot();
BUTTON_TYPES.forEach(type => {
describe(type, () => {
test(`renders the ${type} class`, () => {
const $button = render(<KuiLinkButton type={type} />);
expect($button).toMatchSnapshot();
});
});
});
});
Expand Down
Loading

0 comments on commit 17e0838

Please sign in to comment.