From bc2bc70b6d119db51d6547f1e61d59ccccb09eaf Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Mon, 24 Jul 2017 15:50:17 -0700 Subject: [PATCH] Update Typography and Icon tests. (#13081) --- .../icon/__snapshots__/icon.test.js.snap | 104 +++++++++++++++++- ui_framework/src/components/icon/icon.js | 2 +- ui_framework/src/components/icon/icon.test.js | 24 +++- .../__snapshots__/typography.test.js.snap | 20 ++-- .../src/components/typography/typography.js | 2 +- 5 files changed, 131 insertions(+), 21 deletions(-) diff --git a/ui_framework/src/components/icon/__snapshots__/icon.test.js.snap b/ui_framework/src/components/icon/__snapshots__/icon.test.js.snap index c8c280694d2756..cce8bad6a8d140 100644 --- a/ui_framework/src/components/icon/__snapshots__/icon.test.js.snap +++ b/ui_framework/src/components/icon/__snapshots__/icon.test.js.snap @@ -5,37 +5,75 @@ exports[`KuiIcon is rendered 1`] = ` aria-label="aria-label" class="kuiIcon testClass1 testClass2 kuiIcon--medium" data-test-subj="test subject string" -/> +> + + search icon + + + `; exports[`KuiIcon renders size large 1`] = ` +> + + search icon + + + `; exports[`KuiIcon renders size medium 1`] = ` +> + + search icon + + + `; exports[`KuiIcon renders size xLarge 1`] = ` +> + + search icon + + + `; exports[`KuiIcon renders size xxLarge 1`] = ` +> + + search icon + + + `; exports[`KuiIcon renders type apps 1`] = ` + + apps icon + @@ -46,6 +84,9 @@ exports[`KuiIcon renders type dashboardApp 1`] = ` + + dashboard app icon + @@ -56,6 +97,9 @@ exports[`KuiIcon renders type devToolsApp 1`] = ` + + dev tools app icon + @@ -66,6 +110,9 @@ exports[`KuiIcon renders type discoverApp 1`] = ` + + discover app icon + @@ -76,6 +123,9 @@ exports[`KuiIcon renders type graphApp 1`] = ` + + graph app icon + @@ -86,6 +136,9 @@ exports[`KuiIcon renders type kibanaLogo 1`] = ` + + kibana logo icon + @@ -96,6 +149,9 @@ exports[`KuiIcon renders type machineLearningApp 1`] = ` + + machine learning app icon + @@ -106,6 +162,9 @@ exports[`KuiIcon renders type search 1`] = ` + + search icon + @@ -116,6 +175,9 @@ exports[`KuiIcon renders type timelionApp 1`] = ` + + timelion app icon + @@ -126,6 +188,9 @@ exports[`KuiIcon renders type user 1`] = ` + + user icon + @@ -136,8 +201,37 @@ exports[`KuiIcon renders type visualizeApp 1`] = ` + + visualize app icon + `; + +exports[`KuiIcon title defaults to a humanized version of the type 1`] = ` + + + dashboard app icon + + + +`; + +exports[`KuiIcon title is rendered 1`] = ` + + + a custom title + + + +`; diff --git a/ui_framework/src/components/icon/icon.js b/ui_framework/src/components/icon/icon.js index 9b368c6f63865c..43b783ac03cec6 100644 --- a/ui_framework/src/components/icon/icon.js +++ b/ui_framework/src/components/icon/icon.js @@ -57,7 +57,7 @@ export const KuiIcon = ({ title ? {title} : {`${humanizeCamelCase(type)} icon`}; - const svgReference = type ? : undefined; + const svgReference = ; return ( { test('is rendered', () => { const component = render( - + ); expect(component) .toMatchSnapshot(); }); + describe('title', () => { + test('defaults to a humanized version of the type', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + + test('is rendered', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + describe('renders size', () => { SIZES.forEach(size => { test(size, () => { const component = render( - + ); expect(component) diff --git a/ui_framework/src/components/typography/__snapshots__/typography.test.js.snap b/ui_framework/src/components/typography/__snapshots__/typography.test.js.snap index 723f84a968d067..7ba379ea5a622d 100644 --- a/ui_framework/src/components/typography/__snapshots__/typography.test.js.snap +++ b/ui_framework/src/components/typography/__snapshots__/typography.test.js.snap @@ -1,40 +1,36 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`KuiLargeTitle is rendered 1`] = ` +exports[`KuiText is rendered 1`] = `

Hello

`; -exports[`KuiMediumTitle is rendered 1`] = ` +exports[`KuiTitle is rendered 1`] = `

Hello

`; -exports[`KuiSmallTitle is rendered 1`] = ` +exports[`KuiTitle renders size large 1`] = `

Hello

`; -exports[`KuiText is rendered 1`] = ` +exports[`KuiTitle renders size small 1`] = `

Hello

diff --git a/ui_framework/src/components/typography/typography.js b/ui_framework/src/components/typography/typography.js index f0c70587b314b1..ce19be035c46c7 100644 --- a/ui_framework/src/components/typography/typography.js +++ b/ui_framework/src/components/typography/typography.js @@ -9,7 +9,7 @@ const sizeToClassNameMap = { large: 'kuiTitle--large', }; -const SIZES = Object.keys(sizeToClassNameMap); +export const SIZES = Object.keys(sizeToClassNameMap); export const KuiTitle = ({ size, children, className, ...rest }) => { const classes = classNames('kuiTitle', sizeToClassNameMap[size], className);