From 321e2dd1068be16934eff44e90ceb7dd23cdd7ef Mon Sep 17 00:00:00 2001 From: juliajforesti Date: Fri, 10 May 2024 12:30:55 -0300 Subject: [PATCH 1/5] feat: `InputBox` small variant --- .../components/InputBox/InputBox.stories.tsx | 24 ++++++++++++++- .../components/InputBox/InputBox.styles.scss | 29 +++++++++++++++++++ .../src/components/InputBox/InputBox.tsx | 4 +++ .../fuselage/src/components/Select/Select.tsx | 1 + .../src/components/Select/SelectAria.tsx | 5 ++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/fuselage/src/components/InputBox/InputBox.stories.tsx b/packages/fuselage/src/components/InputBox/InputBox.stories.tsx index ff8ba77d15..e54b46276b 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.stories.tsx +++ b/packages/fuselage/src/components/InputBox/InputBox.stories.tsx @@ -9,7 +9,7 @@ import { import type { ComponentStory, ComponentMeta } from '@storybook/react'; import React from 'react'; -import { Icon, InputBox } from '../..'; +import { Icon, InputBox, Box } from '../..'; export default { title: 'Inputs/InputBox', @@ -87,3 +87,25 @@ export const Skeleton: ComponentStory = () => ( ); Skeleton.storyName = 'InputBox.Skeleton'; + +export const SmallVariants: ComponentStory = () => ( + + + } + /> + +); +SmallVariants.args = { + placeholder: 'Search', + small: true, + onChange: action('change'), +}; diff --git a/packages/fuselage/src/components/InputBox/InputBox.styles.scss b/packages/fuselage/src/components/InputBox/InputBox.styles.scss index f8a8a9ce32..871485ab45 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.styles.scss +++ b/packages/fuselage/src/components/InputBox/InputBox.styles.scss @@ -193,6 +193,31 @@ } } + &__wrapper:has(.rcx-input-box--small) { + align-items: center; + + min-width: lengths.size(112); + max-height: lengths.size(28); + padding: lengths.padding(4) lengths.padding(16); + } + + &--small { + @include typography.use-font-scale(c1); + + &:not(.rcx-input-box--undecorated) { + @extend %input; + min-width: lengths.size(112); + + min-height: lengths.size(28); + padding: lengths.padding(4) lengths.padding(16); + + &:invalid, + &.invalid { + @extend %input--invalid; + } + } + } + @include with-colors( $color: $input-colors-color, $placeholder-color: $input-colors-placeholder-color, @@ -241,6 +266,10 @@ .rcx-input-box__wrapper > & { width: lengths.size(none); min-width: lengths.size(none); + + &--small { + padding: lengths.padding(none); + } } } diff --git a/packages/fuselage/src/components/InputBox/InputBox.tsx b/packages/fuselage/src/components/InputBox/InputBox.tsx index 0345313b60..b7ebc8c3da 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.tsx +++ b/packages/fuselage/src/components/InputBox/InputBox.tsx @@ -23,6 +23,7 @@ type InputBoxProps = ComponentProps & { error?: string; placeholder?: string; placeholderVisible?: boolean; + small?: boolean; type: | 'button' | 'checkbox' @@ -69,6 +70,7 @@ export const InputBox = forwardRef(function InputBox( multiple, placeholderVisible, type = 'text', + small, onChange, ...props }: InputBoxProps, @@ -140,6 +142,7 @@ export const InputBox = forwardRef(function InputBox( rcx-input-box--multiple={multiple} rcx-input-box--placeholder-visible={placeholderVisible} rcx-input-box--type={type} + rcx-input-box--small={small} {...props} /> ); @@ -173,6 +176,7 @@ export const InputBox = forwardRef(function InputBox( rcx-input-box--placeholder-visible={placeholderVisible} rcx-input-box--type={type} rcx-input-box--undecorated + rcx-input-box--small={small} {...props} /> diff --git a/packages/fuselage/src/components/Select/Select.tsx b/packages/fuselage/src/components/Select/Select.tsx index b7db3d1153..1ce753e5e3 100644 --- a/packages/fuselage/src/components/Select/Select.tsx +++ b/packages/fuselage/src/components/Select/Select.tsx @@ -16,6 +16,7 @@ type SelectProps = Omit< value?: V | null; onChange?: ((key: V) => any) | undefined; options: SelectOption[]; + small?: boolean; } & Omit, 'onChange'>; export const Select = forwardRef(function Select< diff --git a/packages/fuselage/src/components/Select/SelectAria.tsx b/packages/fuselage/src/components/Select/SelectAria.tsx index 631c85b4b8..1ca961d0ac 100644 --- a/packages/fuselage/src/components/Select/SelectAria.tsx +++ b/packages/fuselage/src/components/Select/SelectAria.tsx @@ -26,12 +26,14 @@ export const SelectAria = forwardRef(function SelectAria( placeholder, value, onChange, + small, ...props }: Omit, 'value' | 'onChange'> & { error?: string; placeholder?: string; value?: Key | null; onChange?: ((key: Key) => any) | undefined; + small?: boolean; } & React.AllHTMLAttributes, outerRef: Ref ) { @@ -55,6 +57,7 @@ export const SelectAria = forwardRef(function SelectAria( return ( <> ( fontScale='p2' ref={mergedRef} justifyContent='space-between' + rcx-input-box--small={small} className={[ error && 'invalid', disabled && 'disabled', @@ -82,6 +86,7 @@ export const SelectAria = forwardRef(function SelectAria( is='span' {...valueProps} color={state.selectedItem ? 'default' : 'hint'} + {...(small && { fontScale: 'c1' })} > {state.selectedItem ? state.selectedItem.rendered : placeholder} From 9e64df08c91a2f6a3c8d9a8dcf22c2d34817ef05 Mon Sep 17 00:00:00 2001 From: juliajforesti Date: Fri, 10 May 2024 12:49:33 -0300 Subject: [PATCH 2/5] chore: add small variant to `states variations` on inputs stories --- .../EmailInput/EmailInput.stories.tsx | 74 ++++++++++----- .../NumberInput/NumberInput.stories.tsx | 71 +++++++++----- .../PasswordInput/PasswordInput.stories.tsx | 65 ++++++++----- .../SearchInput/SearchInput.stories.tsx | 74 ++++++++++----- .../src/components/Select/Select.stories.tsx | 29 ++++++ .../SelectInput/SelectInput.stories.tsx | 93 +++++++++++++------ .../TelephoneInput/TelephoneInput.stories.tsx | 74 ++++++++++----- .../TextInput/TextInput.stories.tsx | 74 ++++++++++----- .../components/UrlInput/UrlInput.stories.tsx | 74 ++++++++++----- 9 files changed, 436 insertions(+), 192 deletions(-) diff --git a/packages/fuselage/src/components/EmailInput/EmailInput.stories.tsx b/packages/fuselage/src/components/EmailInput/EmailInput.stories.tsx index 40116efe15..cad5602879 100644 --- a/packages/fuselage/src/components/EmailInput/EmailInput.stories.tsx +++ b/packages/fuselage/src/components/EmailInput/EmailInput.stories.tsx @@ -59,28 +59,54 @@ WithValue.args = { }; export const States: ComponentStory = () => ( - {} }} - xAxis={{ - 'default': {}, - 'with placeholder': { placeholder: 'Placeholder' }, - 'with value': { value: 'support@rocket.chat' }, - 'with icon': { - addon: , - value: 'support@rocket.chat', - }, - }} - yAxis={{ - 'default': {}, - 'hover': { className: 'hover' }, - 'active': { className: 'active' }, - 'focus': { className: 'focus' }, - 'disabled': { disabled: true }, - 'errored': { error: 'Error' }, - 'errored + hover': { className: 'hover', error: 'Error' }, - 'errored + active': { className: 'active', error: 'Error' }, - 'errored + focus': { className: 'focus', error: 'Error' }, - }} - /> + <> + {} }} + xAxis={{ + 'default': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'support@rocket.chat' }, + 'with icon': { + addon: , + value: 'support@rocket.chat', + }, + }} + yAxis={{ + 'default': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + {}, small: true }} + xAxis={{ + 'small': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'support@rocket.chat' }, + 'with icon': { + addon: , + value: 'support@rocket.chat', + }, + }} + yAxis={{ + 'small': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + ); diff --git a/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx b/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx index 03fd7db447..0e9bde15da 100644 --- a/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx +++ b/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx @@ -60,25 +60,54 @@ WithPlaceholder.args = { }; export const States: ComponentStory = () => ( - {} }} - xAxis={{ - 'default': {}, - 'with placeholder': { placeholder: 'Placeholder' }, - 'with value': { value: 1024 }, - 'with icon': { addon: , value: 1024 }, - }} - yAxis={{ - 'default': {}, - 'hover': { className: 'hover' }, - 'active': { className: 'active' }, - 'focus': { className: 'focus' }, - 'disabled': { disabled: true }, - 'errored': { error: 'Error' }, - 'errored + hover': { className: 'hover', error: 'Error' }, - 'errored + active': { className: 'active', error: 'Error' }, - 'errored + focus': { className: 'focus', error: 'Error' }, - }} - /> + <> + {} }} + xAxis={{ + 'default': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 1024 }, + 'with icon': { + addon: , + value: 1024, + }, + }} + yAxis={{ + 'default': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + {}, small: true }} + xAxis={{ + 'small': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 1024 }, + 'with icon': { + addon: , + value: 1024, + }, + }} + yAxis={{ + 'small': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + ); diff --git a/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx b/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx index b00d0f399d..76923a44cf 100644 --- a/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx +++ b/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx @@ -26,25 +26,48 @@ export const WithPlaceholder = () => ( ); export const States = () => ( - undefined }} - xAxis={{ - 'default': {}, - 'with placeholder': { placeholder: 'Placeholder' }, - 'with value': { value: 'Value' }, - 'with icon': { addon: , value: 'Value' }, - }} - yAxis={{ - 'default': {}, - 'hover': { className: 'hover' }, - 'active': { className: 'active' }, - 'focus': { className: 'focus' }, - 'disabled': { disabled: true }, - 'errored': { error: 'Error' }, - 'errored + hover': { className: 'hover', error: 'Error' }, - 'errored + active': { className: 'active', error: 'Error' }, - 'errored + focus': { className: 'focus', error: 'Error' }, - }} - /> + <> + undefined }} + xAxis={{ + 'default': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'Value' }, + 'with icon': { addon: , value: 'Value' }, + }} + yAxis={{ + 'default': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + undefined, small: true }} + xAxis={{ + 'small': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'Value' }, + 'with icon': { addon: , value: 'Value' }, + }} + yAxis={{ + 'small': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + ); diff --git a/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx b/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx index 1d116af033..d91c46cecc 100644 --- a/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx +++ b/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx @@ -67,28 +67,54 @@ WithValue.args = { }; export const States: ComponentStory = () => ( - {} }} - xAxis={{ - 'default': {}, - 'with placeholder': { placeholder: 'Placeholder' }, - 'with value': { value: 'Value' }, - 'with icon': { - addon: , - value: 'Value', - }, - }} - yAxis={{ - 'default': {}, - 'hover': { className: 'hover' }, - 'active': { className: 'active' }, - 'focus': { className: 'focus' }, - 'disabled': { disabled: true }, - 'errored': { error: 'Error' }, - 'errored + hover': { className: 'hover', error: 'Error' }, - 'errored + active': { className: 'active', error: 'Error' }, - 'errored + focus': { className: 'focus', error: 'Error' }, - }} - /> + <> + {} }} + xAxis={{ + 'default': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'Value' }, + 'with icon': { + addon: , + value: 'Value', + }, + }} + yAxis={{ + 'default': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + {}, small: true }} + xAxis={{ + 'small': {}, + 'with placeholder': { placeholder: 'Placeholder' }, + 'with value': { value: 'Value' }, + 'with icon': { + addon: , + value: 'Value', + }, + }} + yAxis={{ + 'small': {}, + 'hover': { className: 'hover' }, + 'active': { className: 'active' }, + 'focus': { className: 'focus' }, + 'disabled': { disabled: true }, + 'errored': { error: 'Error' }, + 'errored + hover': { className: 'hover', error: 'Error' }, + 'errored + active': { className: 'active', error: 'Error' }, + 'errored + focus': { className: 'focus', error: 'Error' }, + }} + /> + ); diff --git a/packages/fuselage/src/components/Select/Select.stories.tsx b/packages/fuselage/src/components/Select/Select.stories.tsx index 6e2679d42b..eb7de88eac 100644 --- a/packages/fuselage/src/components/Select/Select.stories.tsx +++ b/packages/fuselage/src/components/Select/Select.stories.tsx @@ -10,6 +10,7 @@ import React from 'react'; import type { SelectOption } from '../..'; import { Select } from '../..'; +import PropsVariationSection from '../../.storybook/PropsVariation'; const options: SelectOption[] = Array.from({ length: 12, @@ -78,3 +79,31 @@ NoPlaceholder.args = { 'aria-label': 'No placeholder select', options, }; + +export const States = () => ( + <> + + + +`; + +exports[`[EmailInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[EmailInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[EmailInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[EmailInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[EmailInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[EmailInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/InputBox/InputBox.spec.tsx b/packages/fuselage/src/components/InputBox/InputBox.spec.tsx index fa45915f2b..a25deddfc2 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.spec.tsx +++ b/packages/fuselage/src/components/InputBox/InputBox.spec.tsx @@ -1,14 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { InputBox } from '.'; +import * as stories from './InputBox.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[InputBox Component]', () => { - it('renders InputBox without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); - it('renders InputBox.Skeleton without crashing', () => { - render(); - }); + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/InputBox/InputBox.stories.tsx b/packages/fuselage/src/components/InputBox/InputBox.stories.tsx index e54b46276b..012ee29523 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.stories.tsx +++ b/packages/fuselage/src/components/InputBox/InputBox.stories.tsx @@ -34,7 +34,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + ); export const Default: ComponentStory = Template.bind({}); @@ -95,12 +95,13 @@ export const SmallVariants: ComponentStory = () => ( alignItems='flex-start' style={{ gap: '8px' }} > - + } + aria-label='Search' /> ); diff --git a/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap b/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap new file mode 100644 index 0000000000..8bc72718a0 --- /dev/null +++ b/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap @@ -0,0 +1,195 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[InputBox Component] renders Date without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders InputBox.Skeleton without crashing 1`] = ` + +
+
+ +
+
+ +`; + +exports[`[InputBox Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders SmallVariants without crashing 1`] = ` + +
+
+ + +
+
+ +`; + +exports[`[InputBox Component] renders Time without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders WithAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[InputBox Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx b/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx index 88264ab948..71a888af1f 100644 --- a/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx +++ b/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { NumberInput } from '.'; +import * as stories from './NumberInput.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[NumberInput Component]', () => { - it('renders without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx b/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx index 0e9bde15da..a69a01fbc7 100644 --- a/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx +++ b/packages/fuselage/src/components/NumberInput/NumberInput.stories.tsx @@ -33,7 +33,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + ); export const Default: ComponentStory = Template.bind({}); @@ -63,7 +63,7 @@ export const States: ComponentStory = () => ( <> {} }} + common={{ 'onChange': () => {}, 'aria-label': 'number' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -87,7 +87,7 @@ export const States: ComponentStory = () => ( /> {}, small: true }} + common={{ 'onChange': () => {}, 'small': true, 'aria-label': 'number' }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap b/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap new file mode 100644 index 0000000000..c29fae6f78 --- /dev/null +++ b/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap @@ -0,0 +1,1655 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[NumberInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[NumberInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[NumberInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[NumberInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[NumberInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[NumberInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx b/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx index d33439159b..deb2544900 100644 --- a/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx +++ b/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import PasswordInput from '.'; +import * as stories from './PasswordInput.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[PasswordInput Component]', () => { - it('renders without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx b/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx index 76923a44cf..815c4b700d 100644 --- a/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx +++ b/packages/fuselage/src/components/PasswordInput/PasswordInput.stories.tsx @@ -1,35 +1,42 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; import React from 'react'; import { Icon, PasswordInput } from '../..'; -import PropsVariation from '../../.storybook/PropsVariation'; +import { PropsVariationSection } from '../../../.storybook/helpers'; export default { title: 'Inputs/PasswordInput', component: PasswordInput, parameters: { jest: ['PasswordInput.spec.tsx'] }, -}; +} as ComponentMeta; -export const Default = () => ; +export const Default: ComponentStory = () => ( + +); -export const WithValue = () => ; +export const WithValue = () => ( + +); export const WithIconAddon = () => ( - } /> + } /> ); -export const Invalid = () => ; +export const Invalid = () => ( + +); -export const Disabled = () => ; +export const Disabled = () => ; export const WithPlaceholder = () => ( - + ); export const States = () => ( <> - undefined }} + common={{ 'onChange': () => undefined, 'aria-label': 'password' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -48,9 +55,13 @@ export const States = () => ( 'errored + focus': { className: 'focus', error: 'Error' }, }} /> - undefined, small: true }} + common={{ + 'onChange': () => undefined, + 'small': true, + 'aria-label': 'password', + }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap b/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap new file mode 100644 index 0000000000..c16663cd2e --- /dev/null +++ b/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap @@ -0,0 +1,2495 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[PasswordInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[PasswordInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[PasswordInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[PasswordInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[PasswordInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[PasswordInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[PasswordInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/SearchInput/SearchInput.spec.tsx b/packages/fuselage/src/components/SearchInput/SearchInput.spec.tsx index f514dd320f..648f18ca7b 100644 --- a/packages/fuselage/src/components/SearchInput/SearchInput.spec.tsx +++ b/packages/fuselage/src/components/SearchInput/SearchInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { SearchInput } from '.'; +import * as stories from './SearchInput.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[SearchInput Component]', () => { - it('renders without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx b/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx index d91c46cecc..d4878cda45 100644 --- a/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx +++ b/packages/fuselage/src/components/SearchInput/SearchInput.stories.tsx @@ -33,7 +33,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + ); export const Default: ComponentStory = Template.bind({}); @@ -70,7 +70,7 @@ export const States: ComponentStory = () => ( <> {} }} + common={{ 'onChange': () => {}, 'aria-label': 'search' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -94,7 +94,7 @@ export const States: ComponentStory = () => ( /> {}, small: true }} + common={{ 'onChange': () => {}, 'small': true, 'aria-label': 'search' }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/SearchInput/__snapshots__/SearchInput.spec.tsx.snap b/packages/fuselage/src/components/SearchInput/__snapshots__/SearchInput.spec.tsx.snap new file mode 100644 index 0000000000..0ed896609d --- /dev/null +++ b/packages/fuselage/src/components/SearchInput/__snapshots__/SearchInput.spec.tsx.snap @@ -0,0 +1,1669 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[SearchInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SearchInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SearchInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SearchInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[SearchInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SearchInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SearchInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/Select/Select.stories.tsx b/packages/fuselage/src/components/Select/Select.stories.tsx index eb7de88eac..5023b304f2 100644 --- a/packages/fuselage/src/components/Select/Select.stories.tsx +++ b/packages/fuselage/src/components/Select/Select.stories.tsx @@ -37,12 +37,21 @@ export default { }, } as ComponentMeta; -const Template: ComponentStory = (args) => +); const TemplateControlled: ComponentStory = (args) => { const [value, setValue] = React.useState('3'); - return + ); }; export const Default: ComponentStory = Template.bind({}); @@ -83,7 +92,9 @@ NoPlaceholder.args = { export const States = () => ( <> + )} common={{ onChange: () => {}, }} diff --git a/packages/fuselage/src/components/SelectInput/SelectInput.spec.tsx b/packages/fuselage/src/components/SelectInput/SelectInput.spec.tsx index ac32100909..1d00c170f7 100644 --- a/packages/fuselage/src/components/SelectInput/SelectInput.spec.tsx +++ b/packages/fuselage/src/components/SelectInput/SelectInput.spec.tsx @@ -1,8 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { SelectInput } from '.'; +import * as stories from './SelectInput.stories'; -it('renders without crashing', () => { - render(); +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); + +describe('[SelectInput Component]', () => { + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/SelectInput/SelectInput.stories.tsx b/packages/fuselage/src/components/SelectInput/SelectInput.stories.tsx index afa8135c8b..76f106549a 100644 --- a/packages/fuselage/src/components/SelectInput/SelectInput.stories.tsx +++ b/packages/fuselage/src/components/SelectInput/SelectInput.stories.tsx @@ -34,7 +34,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + Item A Item B Item C @@ -87,14 +87,15 @@ export const States: ComponentStory = () => ( Item A Item B Item C ), - onChange: () => {}, + 'onChange': () => {}, }} xAxis={{ 'default': {}, @@ -117,15 +118,16 @@ export const States: ComponentStory = () => ( Item A Item B Item C ), - onChange: () => {}, - small: true, + 'onChange': () => {}, + 'small': true, }} xAxis={{ 'small': {}, diff --git a/packages/fuselage/src/components/SelectInput/__snapshots__/SelectInput.spec.tsx.snap b/packages/fuselage/src/components/SelectInput/__snapshots__/SelectInput.spec.tsx.snap new file mode 100644 index 0000000000..12bee89051 --- /dev/null +++ b/packages/fuselage/src/components/SelectInput/__snapshots__/SelectInput.spec.tsx.snap @@ -0,0 +1,3802 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[SelectInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders Multiple without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders MultipleWithAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + multiple +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + multiple +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[SelectInput Component] renders WithAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[SelectInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/TelephoneInput/TelephoneInput.spec.tsx b/packages/fuselage/src/components/TelephoneInput/TelephoneInput.spec.tsx index 7d5cbe55af..4d1f8f5bff 100644 --- a/packages/fuselage/src/components/TelephoneInput/TelephoneInput.spec.tsx +++ b/packages/fuselage/src/components/TelephoneInput/TelephoneInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { TelephoneInput } from '.'; +import * as stories from './TelephoneInput.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[TelephoneInput Component]', () => { - it('renders without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/TelephoneInput/TelephoneInput.stories.tsx b/packages/fuselage/src/components/TelephoneInput/TelephoneInput.stories.tsx index faa185542e..9fd60d56c8 100644 --- a/packages/fuselage/src/components/TelephoneInput/TelephoneInput.stories.tsx +++ b/packages/fuselage/src/components/TelephoneInput/TelephoneInput.stories.tsx @@ -26,7 +26,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + ); export const Default: ComponentStory = Template.bind({}); @@ -60,7 +60,7 @@ export const States: ComponentStory = () => ( <> {} }} + common={{ 'onChange': () => {}, 'aria-label': 'telephone' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -84,7 +84,11 @@ export const States: ComponentStory = () => ( /> {}, small: true }} + common={{ + 'onChange': () => {}, + 'small': true, + 'aria-label': 'telephone', + }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/TelephoneInput/__snapshots__/TelephoneInput.spec.tsx.snap b/packages/fuselage/src/components/TelephoneInput/__snapshots__/TelephoneInput.spec.tsx.snap new file mode 100644 index 0000000000..ae67309cf3 --- /dev/null +++ b/packages/fuselage/src/components/TelephoneInput/__snapshots__/TelephoneInput.spec.tsx.snap @@ -0,0 +1,1669 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[TelephoneInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TelephoneInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TelephoneInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TelephoneInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[TelephoneInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TelephoneInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TelephoneInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/TextInput/TextInput.spec.tsx b/packages/fuselage/src/components/TextInput/TextInput.spec.tsx index bc9d399891..54021ca354 100644 --- a/packages/fuselage/src/components/TextInput/TextInput.spec.tsx +++ b/packages/fuselage/src/components/TextInput/TextInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import { TextInput } from '.'; +import * as stories from './TextInput.stories'; -describe('[TextInput]', () => { - it('renders without crashing', () => { - render(); - }); +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); + +describe('[TextInput Component]', () => { + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/TextInput/TextInput.stories.tsx b/packages/fuselage/src/components/TextInput/TextInput.stories.tsx index e54132b7f4..88829e6984 100644 --- a/packages/fuselage/src/components/TextInput/TextInput.stories.tsx +++ b/packages/fuselage/src/components/TextInput/TextInput.stories.tsx @@ -26,7 +26,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - + ); export const Default: ComponentStory = Template.bind({}); @@ -64,7 +64,7 @@ export const States: ComponentStory = () => ( <> {} }} + common={{ 'onChange': () => {}, 'aria-label': 'text' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -88,7 +88,7 @@ export const States: ComponentStory = () => ( /> {}, small: true }} + common={{ 'onChange': () => {}, 'small': true, 'aria-label': 'text' }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/TextInput/__snapshots__/TextInput.spec.tsx.snap b/packages/fuselage/src/components/TextInput/__snapshots__/TextInput.spec.tsx.snap new file mode 100644 index 0000000000..7145048bac --- /dev/null +++ b/packages/fuselage/src/components/TextInput/__snapshots__/TextInput.spec.tsx.snap @@ -0,0 +1,1669 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[TextInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TextInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TextInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TextInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[TextInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TextInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[TextInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; diff --git a/packages/fuselage/src/components/UrlInput/UrlInput.spec.tsx b/packages/fuselage/src/components/UrlInput/UrlInput.spec.tsx index c86b8a6572..6d1282c4a1 100644 --- a/packages/fuselage/src/components/UrlInput/UrlInput.spec.tsx +++ b/packages/fuselage/src/components/UrlInput/UrlInput.spec.tsx @@ -1,10 +1,31 @@ +import { composeStories } from '@storybook/testing-react'; import { render } from '@testing-library/react'; +import { axe } from 'jest-axe'; import React from 'react'; -import UrlInput from '.'; +import * as stories from './UrlInput.stories'; + +const testCases = Object.values(composeStories(stories)).map((Story) => [ + Story.storyName || 'Story', + Story, +]); describe('[UrlInput Component]', () => { - it('renders without crashing', () => { - render(); - }); + test.each(testCases)( + `renders %s without crashing`, + async (_storyname, Story) => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + } + ); + + test.each(testCases)( + '%s should have no a11y violations', + async (_storyname, Story) => { + const { container } = render(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + } + ); }); diff --git a/packages/fuselage/src/components/UrlInput/UrlInput.stories.tsx b/packages/fuselage/src/components/UrlInput/UrlInput.stories.tsx index ca40e75050..2710a10730 100644 --- a/packages/fuselage/src/components/UrlInput/UrlInput.stories.tsx +++ b/packages/fuselage/src/components/UrlInput/UrlInput.stories.tsx @@ -1,7 +1,8 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; import React from 'react'; import { Icon, UrlInput } from '../..'; -import PropsVariation from '../../.storybook/PropsVariation'; +import { PropsVariationSection } from '../../../.storybook/helpers'; export default { title: 'Inputs/UrlInput', @@ -9,27 +10,33 @@ export default { parameters: { jest: ['UrlInput.spec.tsx'], }, -}; +} as ComponentMeta; -export const Default = () => ; +export const Default: ComponentStory = () => ( + +); export const WithIconAddon = () => ( - } /> + } /> ); -export const Invalid = () => ; +export const Invalid = () => ; -export const Disabled = () => ; +export const Disabled = () => ; -export const WithPlaceholder = () => ; +export const WithPlaceholder = () => ( + +); -export const WithValue = () => ; +export const WithValue = () => ( + +); export const States = () => ( <> - undefined }} + common={{ 'onChange': () => undefined, 'aria-label': 'url' }} xAxis={{ 'default': {}, 'with placeholder': { placeholder: 'Placeholder' }, @@ -51,9 +58,13 @@ export const States = () => ( 'errored + focus': { className: 'focus', error: 'Error' }, }} /> - undefined, small: true }} + common={{ + 'onChange': () => undefined, + 'small': true, + 'aria-label': 'url', + }} xAxis={{ 'small': {}, 'with placeholder': { placeholder: 'Placeholder' }, diff --git a/packages/fuselage/src/components/UrlInput/__snapshots__/UrlInput.spec.tsx.snap b/packages/fuselage/src/components/UrlInput/__snapshots__/UrlInput.spec.tsx.snap new file mode 100644 index 0000000000..38e77e64fb --- /dev/null +++ b/packages/fuselage/src/components/UrlInput/__snapshots__/UrlInput.spec.tsx.snap @@ -0,0 +1,1669 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`[UrlInput Component] renders Default without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[UrlInput Component] renders Disabled without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[UrlInput Component] renders Invalid without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[UrlInput Component] renders States without crashing 1`] = ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ default + + with placeholder + + with value + + with icon +
+ default + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ small + + with placeholder + + with value + + with icon +
+ small + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ disabled + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + hover + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + active + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ errored + focus + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +`; + +exports[`[UrlInput Component] renders WithIconAddon without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[UrlInput Component] renders WithPlaceholder without crashing 1`] = ` + +
+ +
+ +`; + +exports[`[UrlInput Component] renders WithValue without crashing 1`] = ` + +
+ +
+ +`; From 8eb9720d0f5d771bd06adc3789ef0639eb2509b6 Mon Sep 17 00:00:00 2001 From: juliajforesti Date: Fri, 10 May 2024 16:57:24 -0300 Subject: [PATCH 5/5] chore: update tests and snaps --- .../components/EmailInput/EmailInput.spec.tsx | 29 +- .../__snapshots__/EmailInput.spec.tsx.snap | 1657 +------- .../src/components/InputBox/InputBox.spec.tsx | 29 +- .../__snapshots__/InputBox.spec.tsx.snap | 182 +- .../NumberInput/NumberInput.spec.tsx | 29 +- .../__snapshots__/NumberInput.spec.tsx.snap | 1643 +------ .../PasswordInput/PasswordInput.spec.tsx | 29 +- .../__snapshots__/PasswordInput.spec.tsx.snap | 2469 +---------- .../SearchInput/SearchInput.spec.tsx | 29 +- .../__snapshots__/SearchInput.spec.tsx.snap | 1657 +------- .../SelectInput/SelectInput.spec.tsx | 29 +- .../__snapshots__/SelectInput.spec.tsx.snap | 3758 +---------------- .../TelephoneInput/TelephoneInput.spec.tsx | 29 +- .../TelephoneInput.spec.tsx.snap | 1657 +------- .../components/TextInput/TextInput.spec.tsx | 29 +- .../__snapshots__/TextInput.spec.tsx.snap | 1657 +------- .../src/components/UrlInput/UrlInput.spec.tsx | 29 +- .../__snapshots__/UrlInput.spec.tsx.snap | 1657 +------- 18 files changed, 99 insertions(+), 16499 deletions(-) diff --git a/packages/fuselage/src/components/EmailInput/EmailInput.spec.tsx b/packages/fuselage/src/components/EmailInput/EmailInput.spec.tsx index 66eb90789c..849c54dc15 100644 --- a/packages/fuselage/src/components/EmailInput/EmailInput.spec.tsx +++ b/packages/fuselage/src/components/EmailInput/EmailInput.spec.tsx @@ -5,27 +5,18 @@ import React from 'react'; import * as stories from './EmailInput.stories'; -const testCases = Object.values(composeStories(stories)).map((Story) => [ - Story.storyName || 'Story', - Story, -]); +const { Default } = composeStories(stories); describe('[EmailInput Component]', () => { - test.each(testCases)( - `renders %s without crashing`, - async (_storyname, Story) => { - const tree = render(); - expect(tree.baseElement).toMatchSnapshot(); - } - ); + it('renders without crashing', () => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + }); - test.each(testCases)( - '%s should have no a11y violations', - async (_storyname, Story) => { - const { container } = render(); + it('%s should have no a11y violations', async () => { + const { container } = render(); - const results = await axe(container); - expect(results).toHaveNoViolations(); - } - ); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); }); diff --git a/packages/fuselage/src/components/EmailInput/__snapshots__/EmailInput.spec.tsx.snap b/packages/fuselage/src/components/EmailInput/__snapshots__/EmailInput.spec.tsx.snap index c8a9dca46c..f0627fbbda 100644 --- a/packages/fuselage/src/components/EmailInput/__snapshots__/EmailInput.spec.tsx.snap +++ b/packages/fuselage/src/components/EmailInput/__snapshots__/EmailInput.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`[EmailInput Component] renders Default without crashing 1`] = ` +exports[`[EmailInput Component] renders without crashing 1`] = `
`; - -exports[`[EmailInput Component] renders Disabled without crashing 1`] = ` - -
- -
- -`; - -exports[`[EmailInput Component] renders Invalid without crashing 1`] = ` - -
- -
- -`; - -exports[`[EmailInput Component] renders States without crashing 1`] = ` - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- default - - with placeholder - - with value - - with icon -
- default - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- disabled - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- small - - with placeholder - - with value - - with icon -
- small - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- disabled - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -`; - -exports[`[EmailInput Component] renders WithIconAddon without crashing 1`] = ` - -
- -
- -`; - -exports[`[EmailInput Component] renders WithPlaceholder without crashing 1`] = ` - -
- -
- -`; - -exports[`[EmailInput Component] renders WithValue without crashing 1`] = ` - -
- -
- -`; diff --git a/packages/fuselage/src/components/InputBox/InputBox.spec.tsx b/packages/fuselage/src/components/InputBox/InputBox.spec.tsx index a25deddfc2..12c293dc80 100644 --- a/packages/fuselage/src/components/InputBox/InputBox.spec.tsx +++ b/packages/fuselage/src/components/InputBox/InputBox.spec.tsx @@ -5,27 +5,18 @@ import React from 'react'; import * as stories from './InputBox.stories'; -const testCases = Object.values(composeStories(stories)).map((Story) => [ - Story.storyName || 'Story', - Story, -]); +const { Default } = composeStories(stories); describe('[InputBox Component]', () => { - test.each(testCases)( - `renders %s without crashing`, - async (_storyname, Story) => { - const tree = render(); - expect(tree.baseElement).toMatchSnapshot(); - } - ); + it('renders without crashing', () => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + }); - test.each(testCases)( - '%s should have no a11y violations', - async (_storyname, Story) => { - const { container } = render(); + it('%s should have no a11y violations', async () => { + const { container } = render(); - const results = await axe(container); - expect(results).toHaveNoViolations(); - } - ); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); }); diff --git a/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap b/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap index 8bc72718a0..8842b48a93 100644 --- a/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap +++ b/packages/fuselage/src/components/InputBox/__snapshots__/InputBox.spec.tsx.snap @@ -1,77 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`[InputBox Component] renders Date without crashing 1`] = ` - -
- -
- -`; - -exports[`[InputBox Component] renders Default without crashing 1`] = ` - -
- -
- -`; - -exports[`[InputBox Component] renders Disabled without crashing 1`] = ` - -
- -
- -`; - -exports[`[InputBox Component] renders InputBox.Skeleton without crashing 1`] = ` - -
-
- -
-
- -`; - -exports[`[InputBox Component] renders Invalid without crashing 1`] = ` +exports[`[InputBox Component] renders without crashing 1`] = `
`; - -exports[`[InputBox Component] renders SmallVariants without crashing 1`] = ` - -
-
- - -
-
- -`; - -exports[`[InputBox Component] renders Time without crashing 1`] = ` - -
- -
- -`; - -exports[`[InputBox Component] renders WithAddon without crashing 1`] = ` - -
- -
- -`; - -exports[`[InputBox Component] renders WithPlaceholder without crashing 1`] = ` - -
- -
- -`; diff --git a/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx b/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx index 71a888af1f..5146e5df1d 100644 --- a/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx +++ b/packages/fuselage/src/components/NumberInput/NumberInput.spec.tsx @@ -5,27 +5,18 @@ import React from 'react'; import * as stories from './NumberInput.stories'; -const testCases = Object.values(composeStories(stories)).map((Story) => [ - Story.storyName || 'Story', - Story, -]); +const { Default } = composeStories(stories); describe('[NumberInput Component]', () => { - test.each(testCases)( - `renders %s without crashing`, - async (_storyname, Story) => { - const tree = render(); - expect(tree.baseElement).toMatchSnapshot(); - } - ); + it('renders without crashing', () => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + }); - test.each(testCases)( - '%s should have no a11y violations', - async (_storyname, Story) => { - const { container } = render(); + it('%s should have no a11y violations', async () => { + const { container } = render(); - const results = await axe(container); - expect(results).toHaveNoViolations(); - } - ); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); }); diff --git a/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap b/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap index c29fae6f78..0e71bc5018 100644 --- a/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap +++ b/packages/fuselage/src/components/NumberInput/__snapshots__/NumberInput.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`[NumberInput Component] renders Default without crashing 1`] = ` +exports[`[NumberInput Component] renders without crashing 1`] = `
`; - -exports[`[NumberInput Component] renders Disabled without crashing 1`] = ` - -
- -
- -`; - -exports[`[NumberInput Component] renders Invalid without crashing 1`] = ` - -
- -
- -`; - -exports[`[NumberInput Component] renders States without crashing 1`] = ` - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- default - - with placeholder - - with value - - with icon -
- default - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- disabled - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- small - - with placeholder - - with value - - with icon -
- small - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- disabled - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + hover - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + active - -
- -
-
-
- -
-
-
- -
-
-
- -
-
- errored + focus - -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -`; - -exports[`[NumberInput Component] renders WithIconAddon without crashing 1`] = ` - -
- -
- -`; - -exports[`[NumberInput Component] renders WithPlaceholder without crashing 1`] = ` - -
- -
- -`; diff --git a/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx b/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx index deb2544900..6253e6099c 100644 --- a/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx +++ b/packages/fuselage/src/components/PasswordInput/PasswordInput.spec.tsx @@ -5,27 +5,18 @@ import React from 'react'; import * as stories from './PasswordInput.stories'; -const testCases = Object.values(composeStories(stories)).map((Story) => [ - Story.storyName || 'Story', - Story, -]); +const { Default } = composeStories(stories); describe('[PasswordInput Component]', () => { - test.each(testCases)( - `renders %s without crashing`, - async (_storyname, Story) => { - const tree = render(); - expect(tree.baseElement).toMatchSnapshot(); - } - ); + it('renders without crashing', () => { + const tree = render(); + expect(tree.baseElement).toMatchSnapshot(); + }); - test.each(testCases)( - '%s should have no a11y violations', - async (_storyname, Story) => { - const { container } = render(); + it('%s should have no a11y violations', async () => { + const { container } = render(); - const results = await axe(container); - expect(results).toHaveNoViolations(); - } - ); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); }); diff --git a/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap b/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap index c16663cd2e..64c9b1847a 100644 --- a/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap +++ b/packages/fuselage/src/components/PasswordInput/__snapshots__/PasswordInput.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`[PasswordInput Component] renders Default without crashing 1`] = ` +exports[`[PasswordInput Component] renders without crashing 1`] = `