From 322a968d698ecacff55e4ee11c25c2ef13d8f8bb Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Fri, 24 Mar 2017 11:58:45 -0700 Subject: [PATCH] Refactor HTML attribute tests to be more succinct. --- .../button/__snapshots__/button.test.js.snap | 34 ++------ .../__snapshots__/link_button.test.js.snap | 48 +----------- .../__snapshots__/submit_button.test.js.snap | 10 +++ ui_framework/components/button/button.test.js | 54 +++---------- .../components/button/link_button.test.js | 78 ++++--------------- .../components/button/submit_button.test.js | 14 ++++ 6 files changed, 57 insertions(+), 181 deletions(-) diff --git a/ui_framework/components/button/__snapshots__/button.test.js.snap b/ui_framework/components/button/__snapshots__/button.test.js.snap index 86a853ca884fa..ab8b452e7019b 100644 --- a/ui_framework/components/button/__snapshots__/button.test.js.snap +++ b/ui_framework/components/button/__snapshots__/button.test.js.snap @@ -1,43 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`KuiButton Baseline is rendered 1`] = ` - -`; - -exports[`KuiButton HTML attributes aria-label is rendered 1`] = ` +exports[`KuiButton Baseline HTML attributes are rendered 1`] = ` -`; - -exports[`KuiButton HTML attributes className renders the classes 1`] = ` - -`; - -exports[`KuiButton HTML attributes data-test-subj is rendered 1`] = ` - `; -exports[`KuiButton HTML attributes disabled sets the disabled attribute and class 1`] = ` +exports[`KuiButton Baseline is rendered 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 a305c2cc88a6c..6935d87e61b79 100644 --- a/ui_framework/components/button/__snapshots__/link_button.test.js.snap +++ b/ui_framework/components/button/__snapshots__/link_button.test.js.snap @@ -1,60 +1,20 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`KuiLinkButton Baseline is rendered 1`] = ` - - - -`; - -exports[`KuiLinkButton HTML attributes aria-label is rendered 1`] = ` +exports[`KuiLinkButton Baseline HTML attributes are rendered (and disabled renders a class) 1`] = ` - - -`; - -exports[`KuiLinkButton HTML attributes className renders the classes 1`] = ` - - - -`; - -exports[`KuiLinkButton HTML attributes data-test-subj is rendered 1`] = ` - - - -`; - -exports[`KuiLinkButton HTML attributes disabled sets the disabled class 1`] = ` - - - -`; - -exports[`KuiLinkButton HTML attributes href is rendered 1`] = ` - `; -exports[`KuiLinkButton HTML attributes target is rendered 1`] = ` +exports[`KuiLinkButton Baseline is rendered 1`] = ` diff --git a/ui_framework/components/button/__snapshots__/submit_button.test.js.snap b/ui_framework/components/button/__snapshots__/submit_button.test.js.snap index be16b7cbed1e2..9290fe5be2141 100644 --- a/ui_framework/components/button/__snapshots__/submit_button.test.js.snap +++ b/ui_framework/components/button/__snapshots__/submit_button.test.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`KuiSubmitButton Baseline HTML attributes are rendered 1`] = ` + +`; + exports[`KuiSubmitButton Baseline is rendered 1`] = ` { expect($button) .toMatchSnapshot(); }); - }); - - describe('HTML attributes', () => { - describe('aria-label', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('disabled', () => { - test('sets the disabled attribute and class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - describe('data-test-subj', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('className', () => { - test('renders the classes', () => { - const $button = render( - - ); + test('HTML attributes are rendered', () => { + const $button = render( + + ); - expect($button) - .toMatchSnapshot(); - }); + expect($button) + .toMatchSnapshot(); }); }); diff --git a/ui_framework/components/button/link_button.test.js b/ui_framework/components/button/link_button.test.js index acfac6585cfeb..4c2c1078f951d 100644 --- a/ui_framework/components/button/link_button.test.js +++ b/ui_framework/components/button/link_button.test.js @@ -17,73 +17,21 @@ describe('KuiLinkButton', () => { expect($button) .toMatchSnapshot(); }); - }); - - describe('HTML attributes', () => { - describe('href', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('target', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('aria-label', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('disabled', () => { - test('sets the disabled class', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - describe('data-test-subj', () => { - test('is rendered', () => { - const $button = render( - - ); - - expect($button) - .toMatchSnapshot(); - }); - }); - - describe('className', () => { - test('renders the classes', () => { - const $button = render( - - ); + test('HTML attributes are rendered (and disabled renders a class)', () => { + const $button = render( + + ); - expect($button) - .toMatchSnapshot(); - }); + expect($button) + .toMatchSnapshot(); }); }); diff --git a/ui_framework/components/button/submit_button.test.js b/ui_framework/components/button/submit_button.test.js index 2c2c1b95c8f2c..6857b44a22e06 100644 --- a/ui_framework/components/button/submit_button.test.js +++ b/ui_framework/components/button/submit_button.test.js @@ -18,6 +18,20 @@ describe('KuiSubmitButton', () => { expect($button) .toMatchSnapshot(); }); + + test('HTML attributes are rendered', () => { + const $button = render( + + ); + + expect($button) + .toMatchSnapshot(); + }); }); describe('HTML attributes', () => {