From 34980d12dd021dc81ea5a3ce86cad3b481947856 Mon Sep 17 00:00:00 2001 From: Patrick Wolfert Date: Tue, 25 Jan 2022 14:41:06 -0800 Subject: [PATCH] [NO-TICKET] Deprecate Button's "component" prop (#1546) * Add deprecation docs and warning for Button's `component` prop * Update unit tests and story --- .../src/components/Button/Button.stories.jsx | 8 ++- .../src/components/Button/Button.test.tsx | 59 +++++++++++++------ .../src/components/Button/Button.tsx | 12 +++- 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/packages/design-system/src/components/Button/Button.stories.jsx b/packages/design-system/src/components/Button/Button.stories.jsx index a36bc6c0ae..38aa08d482 100644 --- a/packages/design-system/src/components/Button/Button.stories.jsx +++ b/packages/design-system/src/components/Button/Button.stories.jsx @@ -13,9 +13,6 @@ export default { control: { type: 'text' }, type: { name: 'string', required: true }, }, - component: { - control: false, - }, disabled: { control: { type: 'boolean' }, }, @@ -25,6 +22,11 @@ export default { disable: true, }, }, + component: { + table: { + disable: true, + }, + }, // hiding deprecated opts variation: { options: ['primary', 'success', 'transparent'], diff --git a/packages/design-system/src/components/Button/Button.test.tsx b/packages/design-system/src/components/Button/Button.test.tsx index 14b1cbc70f..782ace2898 100644 --- a/packages/design-system/src/components/Button/Button.test.tsx +++ b/packages/design-system/src/components/Button/Button.test.tsx @@ -2,13 +2,16 @@ import Button, { ButtonProps, ButtonComponentType } from './Button'; import React from 'react'; import { shallow } from 'enzyme'; -interface LinkProps { - children: React.ReactNode; - type: 'submit'; - to: string; +function mockWarn(testFunction: () => void) { + const original = console.warn; + const mock = jest.fn(); + console.warn = mock; + testFunction(); + console.warn = original; + return mock; } -const Link = (props: LinkProps) => { +const Link = (props: any) => { return
{props.children}
; }; @@ -49,20 +52,21 @@ describe('Button', () => { }); it('renders as a custom Link component', () => { - const wrapper = shallow( -