diff --git a/webapp/channels/src/components/__snapshots__/save_button.test.tsx.snap b/webapp/channels/src/components/__snapshots__/save_button.test.tsx.snap index 05828e668c..9238579129 100644 --- a/webapp/channels/src/components/__snapshots__/save_button.test.tsx.snap +++ b/webapp/channels/src/components/__snapshots__/save_button.test.tsx.snap @@ -8,7 +8,7 @@ exports[`components/SaveButton should match snapshot, extraClasses 1`] = ` id="saveSetting" type="submit" > - - + `; @@ -35,7 +35,7 @@ exports[`components/SaveButton should match snapshot, on defaultMessage 1`] = ` id="saveSetting" type="submit" > - - + `; @@ -62,7 +62,7 @@ exports[`components/SaveButton should match snapshot, on defaultMessage 2`] = ` id="saveSetting" type="submit" > - Go - + `; @@ -86,7 +86,7 @@ exports[`components/SaveButton should match snapshot, on savingMessage 1`] = ` id="saveSetting" type="submit" > - - + `; @@ -113,7 +113,7 @@ exports[`components/SaveButton should match snapshot, on savingMessage 2`] = ` id="saveSetting" type="submit" > - @@ -123,6 +123,6 @@ exports[`components/SaveButton should match snapshot, on savingMessage 2`] = ` id="save_button.save" /> - + `; diff --git a/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap b/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap index 2272027821..e35663fac2 100644 --- a/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap +++ b/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap @@ -87,7 +87,7 @@ exports[`components/SettingItemMin should match snapshot with active Save button onClick={[Function]} tabIndex={0} > - @@ -95,7 +95,7 @@ exports[`components/SettingItemMin should match snapshot with active Save button defaultMessage="Save" id="setting_picture.save" /> - + `; @@ -22,7 +22,7 @@ exports[`components/SpinnerButton should match snapshot with required props 1`]
- @@ -109,7 +109,7 @@ exports[`components/admin_console/request_button/request_button.jsx should match Button Text - +
- @@ -246,7 +246,7 @@ exports[`components/admin_console/request_button/request_button.jsx should match Button Text - +
- @@ -375,7 +375,7 @@ exports[`components/admin_console/request_button/request_button.jsx should match Button Text - +
- @@ -505,7 +505,7 @@ exports[`components/admin_console/request_button/request_button.jsx should match Button Text - +
- @@ -23,7 +23,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render 1`] = ` defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -87,7 +87,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with empty disabled={false} onClick={[Function]} > - @@ -95,7 +95,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with empty defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -127,7 +127,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with icon 1 disabled={false} onClick={[Function]} > - @@ -135,7 +135,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with icon 1 defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -168,7 +168,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with no hom disabled={false} onClick={[Function]} > - @@ -176,7 +176,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with no hom defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -206,7 +206,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with no plu disabled={false} onClick={[Function]} > - @@ -214,7 +214,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with no plu defaultMessage="Install" id="marketplace_modal.list.install" /> - + } homepageUrl="http://example.com" @@ -244,7 +244,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with one la disabled={false} onClick={[Function]} > - @@ -252,7 +252,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with one la defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -292,7 +292,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with server disabled={false} onClick={[Function]} > - @@ -300,7 +300,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with server defaultMessage="Try Again" id="marketplace_modal.list.try_again" /> - + } description="test plugin" @@ -332,7 +332,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with two la disabled={false} onClick={[Function]} > - @@ -340,7 +340,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem should render with two la defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -385,7 +385,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem when installing 1`] = ` disabled={false} onClick={[Function]} > - @@ -393,7 +393,7 @@ exports[`components/MarketplaceItemApp MarketplaceItem when installing 1`] = ` defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" diff --git a/webapp/channels/src/components/plugin_marketplace/marketplace_item/marketplace_item_plugin/__snapshots__/marketplace_item_plugin.test.tsx.snap b/webapp/channels/src/components/plugin_marketplace/marketplace_item/marketplace_item_plugin/__snapshots__/marketplace_item_plugin.test.tsx.snap index 2c38fb3f73..2a57315698 100644 --- a/webapp/channels/src/components/plugin_marketplace/marketplace_item/marketplace_item_plugin/__snapshots__/marketplace_item_plugin.test.tsx.snap +++ b/webapp/channels/src/components/plugin_marketplace/marketplace_item/marketplace_item_plugin/__snapshots__/marketplace_item_plugin.test.tsx.snap @@ -15,7 +15,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render 1`] = ` disabled={false} onClick={[Function]} > - @@ -23,7 +23,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render 1`] = ` defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -141,7 +141,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with emp disabled={false} onClick={[Function]} > - @@ -149,7 +149,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with emp defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -206,7 +206,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no disabled={false} onClick={[Function]} > - @@ -214,7 +214,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -269,7 +269,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no disabled={false} onClick={[Function]} > - @@ -277,7 +277,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no defaultMessage="Install" id="marketplace_modal.list.install" /> - + } homepageUrl="http://example.com" @@ -332,7 +332,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no disabled={false} onClick={[Function]} > - @@ -340,7 +340,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with no defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -394,7 +394,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with one disabled={false} onClick={[Function]} > - @@ -402,7 +402,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with one defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -467,7 +467,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with plu disabled={false} onClick={[Function]} > - @@ -475,7 +475,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with plu defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" @@ -544,7 +544,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with ser disabled={false} onClick={[Function]} > - @@ -552,7 +552,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with ser defaultMessage="Try Again" id="marketplace_modal.list.try_again" /> - + } description="test plugin" @@ -609,7 +609,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with two disabled={false} onClick={[Function]} > - @@ -617,7 +617,7 @@ exports[`components/MarketplaceItemPlugin MarketplaceItem should render with two defaultMessage="Install" id="marketplace_modal.list.install" /> - + } description="test plugin" diff --git a/webapp/channels/src/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.tsx.snap b/webapp/channels/src/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.tsx.snap index acb761b96f..bac7f86fb9 100644 --- a/webapp/channels/src/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.tsx.snap +++ b/webapp/channels/src/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.tsx.snap @@ -221,7 +221,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should onClick={[Function]} type="submit" > - - + @@ -208,7 +208,7 @@ exports[`components/WarnMetricAckModal should match snapshot, init 1`] = ` disabled={false} onClick={[Function]} > - @@ -216,7 +216,7 @@ exports[`components/WarnMetricAckModal should match snapshot, init 1`] = ` defaultMessage="Acknowledge" id="warn_metric_ack_modal.contact_support" /> - + diff --git a/webapp/channels/src/components/widgets/loading/__snapshots__/loading_wrapper.test.tsx.snap b/webapp/channels/src/components/widgets/loading/__snapshots__/loading_wrapper.test.tsx.snap new file mode 100644 index 0000000000..34bad6be62 --- /dev/null +++ b/webapp/channels/src/components/widgets/loading/__snapshots__/loading_wrapper.test.tsx.snap @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/widgets/loading/LoadingWrapper showing content with children 1`] = ` + + text + +`; + +exports[`components/widgets/loading/LoadingWrapper showing content without children 1`] = ` + +`; + +exports[`components/widgets/loading/LoadingWrapper showing spinner with text 1`] = ` + + + + + + + test + + + +`; + +exports[`components/widgets/loading/LoadingWrapper showing spinner without text 1`] = ` + + + + + + + + + +`; diff --git a/webapp/channels/src/components/widgets/loading/loading_wrapper.test.tsx b/webapp/channels/src/components/widgets/loading/loading_wrapper.test.tsx index 09089ce140..fc76b35386 100644 --- a/webapp/channels/src/components/widgets/loading/loading_wrapper.test.tsx +++ b/webapp/channels/src/components/widgets/loading/loading_wrapper.test.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; +import {mount} from 'enzyme'; import React from 'react'; import LoadingWrapper from './loading_wrapper'; @@ -13,37 +13,25 @@ describe('components/widgets/loading/LoadingWrapper', () => { loading: true, text: 'test', children: 'children', - snapshot: ` - -`, }, { name: 'showing spinner without text', loading: true, children: 'text', - snapshot: ` - -`, }, { name: 'showing content with children', loading: false, children: 'text', - snapshot: '"text"', }, { name: 'showing content without children', loading: false, - snapshot: '""', }, ]; for (const testCase of testCases) { test(testCase.name, () => { - const wrapper = shallow( + const wrapper = mount( { {testCase.children} , ); - expect(wrapper).toMatchInlineSnapshot(testCase.snapshot); + expect(wrapper).toMatchSnapshot(); }); } }); diff --git a/webapp/channels/src/components/widgets/loading/loading_wrapper.tsx b/webapp/channels/src/components/widgets/loading/loading_wrapper.tsx index a26869d08f..91771aa58f 100644 --- a/webapp/channels/src/components/widgets/loading/loading_wrapper.tsx +++ b/webapp/channels/src/components/widgets/loading/loading_wrapper.tsx @@ -6,24 +6,17 @@ import React from 'react'; import LoadingSpinner from './loading_spinner'; type Props = { - loading: boolean; - text: React.ReactNode; - children: React.ReactNode; + loading?: boolean; + text?: React.ReactNode; + children?: React.ReactNode; } -export default class LoadingWrapper extends React.PureComponent { - public static defaultProps: Props = { - loading: true, - text: null, - children: null, - }; +const LoadingWrapper = ({loading = true, text = null, children = null}: Props) => { + return ( + <> + {loading ? : children} + + ); +}; - public render() { - const {text, loading, children} = this.props; - if (!loading) { - return children; - } - - return ; - } -} +export default React.memo(LoadingWrapper);