diff --git a/examples/bpk-component-card-list/examples.module.css b/examples/bpk-component-card-list/examples.module.css deleted file mode 100644 index 32a6409e3c..0000000000 --- a/examples/bpk-component-card-list/examples.module.css +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-card-list-examples__header{display:flex;height:2.5rem;padding:.5rem;justify-content:space-between;align-items:center;color:#fff}.bpk-card-list-examples__wrapper{width:20.5rem}.bpk-destinationCard .bpk-destinationCard-image{border-top-left-radius:.75rem;border-top-right-radius:.75rem;overflow:hidden}.bpk-destinationCard .bpk-bottom{display:flex;padding:1.5rem;justify-content:space-between}.bpk-destinationCard .bpk-column{display:flex;flex-direction:column}.bpk-internalLinkCard{display:flex;overflow:hidden}.bpk-internalLinkCard .bpk-image{flex:0 0 5.5rem}.bpk-internalLinkCard .bpk-info{display:flex;margin:auto 1.5rem;flex-direction:column}.bpk-internalLinkCard .bpk-verticalLinks_bullet{margin:0 .25rem;color:#0062e3} \ No newline at end of file diff --git a/examples/bpk-component-card-list/examples.module.scss b/examples/bpk-component-card-list/examples.module.scss index 2dd29c9d3a..4bf7efaf05 100644 --- a/examples/bpk-component-card-list/examples.module.scss +++ b/examples/bpk-component-card-list/examples.module.scss @@ -16,33 +16,18 @@ * limitations under the License. */ -@import '../../packages/bpk-mixins/index.scss'; +@use '../../packages/unstable__bpk-mixins/tokens'; -.bpk-card-list-examples { - &__header { - display: flex; - height: bpk-spacing-xxl(); - padding: bpk-spacing-md(); - justify-content: space-between; - align-items: center; - color: $bpk-text-on-dark-day; - } - - &__wrapper { - width: bpk-spacing-md() * 41; - } -} - -.bpk-destinationCard { - .bpk-destinationCard-image { - border-top-left-radius: 0.75rem; - border-top-right-radius: 0.75rem; +.bpkdocs-consumer-level { + img { + border-top-left-radius: tokens.$bpk-border-radius-md; + border-top-right-radius: tokens.$bpk-border-radius-md; overflow: hidden; } .bpk-bottom { display: flex; - padding: bpk-spacing-lg(); + padding: tokens.bpk-spacing-lg(); justify-content: space-between; } @@ -52,24 +37,30 @@ } } -.bpk-internalLinkCard { +.bpkdocs-consumer-level__internal-card { display: flex; + flex-direction: row; + align-items: center; overflow: hidden; - .bpk-image { - flex: 0 0 5.5rem; + .bpkdocs-internal-link-img { + width: 20%; + } + + img { + border-top-left-radius: tokens.$bpk-border-radius-md; + border-bottom-left-radius: tokens.$bpk-border-radius-md; } .bpk-info { - display: flex; - margin: auto bpk-spacing-lg(); + margin: auto tokens.bpk-spacing-lg(); flex-direction: column; } .bpk-verticalLinks { &_bullet { - margin: 0 bpk-spacing-sm(); - color: $bpk-core-accent-day; + margin: 0 tokens.bpk-spacing-sm(); + color: tokens.$bpk-core-accent-day; } } } diff --git a/examples/bpk-component-card-list/examples.js b/examples/bpk-component-card-list/examples.tsx similarity index 57% rename from examples/bpk-component-card-list/examples.js rename to examples/bpk-component-card-list/examples.tsx index 0b9963cbba..9fb9f409c7 100644 --- a/examples/bpk-component-card-list/examples.js +++ b/examples/bpk-component-card-list/examples.tsx @@ -22,18 +22,15 @@ import { useState } from 'react'; import BpkCard from '../../packages/bpk-component-card'; import BpkCardList from '../../packages/bpk-component-card-list'; import BpkImage from '../../packages/bpk-component-image'; +// @ts-ignore import BpkLink from '../../packages/bpk-component-link'; import BpkText, { TEXT_STYLES } from '../../packages/bpk-component-text'; import STYLES from './examples.module.scss'; -const DealsCard = (i) => ( +const DealsCard = (i: number) => ( null}> - + {`Let's explore Deal ${i}`} @@ -42,57 +39,74 @@ const DealsCard = (i) => ( ); -const DestinationCard = (i) => ( - - - -
-
- - {`Destination Name ${i}`} - - Country -
- -
- Direct - £100 +const DestinationCard = (i: number) => ( + +
+ + +
+
+ + {`Destination Name ${i}`} + + Country +
+ +
+ Direct + £100 +
); -const InternalLinkCard = (i) => ( - - +const InternalLinkCard = (i: number) => ( + +
+
+ +
-
- {`Amsterdam Schiphol ${i}`} - -
- Flights - - {'\u2022'} - - Hotels - - {'\u2022'} - - Car Hire +
+ {`Amsterdam Schiphol ${i}`} + +
+ Flights + + {'\u2022'} + + Hotels + + {'\u2022'} + + Car Hire +
); -const cards = (cardType) => [...Array(14).keys()].map((i) => cardType(i)); + +type ExampleCard = + | typeof InternalLinkCard + | typeof DealsCard + | typeof DestinationCard; +const cards = (cardType: ExampleCard) => { + const cardList = []; + for (let i = 0; i < 14; i += 1) { + cardList.push(cardType(i)); + } + return cardList; +}; const title = 'Must-visit spots'; const description = @@ -109,14 +123,14 @@ const GridToRailExample = () => { return ( ); }; @@ -132,61 +146,76 @@ const GridToStackExample = () => { return ( ); }; const GridToStackWithButtonExample = () => ( {}} title={title} - description={description} - buttonText="Explore More" /> ); const RowToRailWith5InitiallyShownCardsExample = () => ( ); const RowToRailExample = () => ( ); + +// TODO: this use case is currently not available as proposed due the sturucture of the props +// Row layoutDesktop variant requires accesory of "pagination" +// Stack layoutMobile variant requires accesory of "button" or "expand" +// The component only supports one accessory prop value so cannot cross support 2 different types of accesories const RowToStackExample = () => ( ); diff --git a/packages/bpk-component-card-list/src/BpkCardList-test.tsx b/packages/bpk-component-card-list/src/BpkCardList-test.tsx index 5e7016a34d..322f206bd3 100644 --- a/packages/bpk-component-card-list/src/BpkCardList-test.tsx +++ b/packages/bpk-component-card-list/src/BpkCardList-test.tsx @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import mockCards from '../testMocks'; @@ -23,7 +23,7 @@ import BpkCardList from './BpkCardList'; describe('BpkCardList', () => { it('should render correctly with grid, stack and no accessory', () => { - const { asFragment } = render( + render( { layoutMobile="stack" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with grid, stack and expand accessory', () => { - const { asFragment } = render( + render( { onButtonClick={jest.fn()} />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.getByTestId('button')).toHaveTextContent('Expand'); + expect(screen.getByTestId('button')).toHaveClass( + 'bpk-button bpk-button--link', + ); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with grid, stack and button accessory', () => { - const { asFragment } = render( + render( { href="https://www.skyscanner.net" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryAllByRole('button')[0]).toHaveTextContent('Button'); + expect(screen.queryAllByRole('button')[0]).toHaveClass( + 'bpk-button bpk-button--primary', + ); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with grid, rail and no accessory', () => { - const { asFragment } = render( + render( { layoutMobile="rail" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with grid, rail and expand accessory', () => { - const { asFragment } = render( + render( { onButtonClick={jest.fn()} />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).toHaveTextContent('Expand'); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); }); it('should render correctly with grid, rail and button accessory', () => { - const { asFragment } = render( + render( { href="https://www.skyscanner.net" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryAllByRole('button')[0]).toHaveTextContent('Button'); + expect(screen.queryAllByRole('button')[0]).toHaveClass( + 'bpk-button bpk-button--primary', + ); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); }); it('should render correctly with row, stack and no accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with row, rail and pagination accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(6); + expect( + screen.getByRole('button', { name: 'Previous' }), + ).toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'Go to page 1' }), + ).toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'Go to page 2' }), + ).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Next' })).toBeInTheDocument(); }); it('should render correctly with row, rail and no accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); + expect(screen.queryAllByRole('button', { name: 'Previous' })).toHaveLength( + 0, + ); }); it('should render correctly with header, grid, stack and expand accessory', () => { - const { asFragment } = render( + render( { expandText="Expand" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).toHaveTextContent('Expand'); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with header, grid, stack and no accessory', () => { - const { asFragment } = render( + render( { layoutMobile="stack" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with header, grid, rail and expand accessory', () => { - const { asFragment } = render( + render( { expandText="Expand" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).toHaveTextContent('Expand'); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with header, grid, rail and no accessory', () => { - const { asFragment } = render( + render( { layoutMobile="rail" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-grid'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); }); it('should render correctly with header, row, stack and no accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(6); + expect(screen.queryAllByRole('button', { name: 'Previous' })).toHaveLength( + 0, + ); }); it('should render correctly with header, row, rail and pagination accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(6); + expect(screen.queryAllByRole('button', { name: 'Previous' })).toHaveLength( + 0, + ); }); it('should render correctly with header, row, rail and no accessory', () => { - const { asFragment } = render( + render( { ariaLabelPrev="Previous" />, ); - expect(asFragment()).toMatchSnapshot(); + + expect(screen.getByText('Title')).toBeInTheDocument(); + expect(screen.getByText('Description')).toBeInTheDocument(); + expect(screen.queryByTestId('button')).not.toBeInTheDocument(); + expect( + screen.getByTestId('bpk-card-list--card-list').firstChild, + ).toHaveClass('bpk-card-list-row'); + expect(screen.getAllByRole('button', { name: /Card \d/ })).toHaveLength(2); + expect(screen.queryAllByRole('button', { name: 'Previous' })).toHaveLength( + 0, + ); }); }); diff --git a/packages/bpk-component-card-list/src/BpkCardList.tsx b/packages/bpk-component-card-list/src/BpkCardList.tsx index bbbfa9f30f..c14bb1bd3b 100644 --- a/packages/bpk-component-card-list/src/BpkCardList.tsx +++ b/packages/bpk-component-card-list/src/BpkCardList.tsx @@ -76,7 +76,10 @@ const BpkCardList = (props: CardListProps) => { button={button} /> -
+
{(isActive) => { if (isActive) { @@ -113,7 +116,12 @@ const BpkCardList = (props: CardListProps) => { } if (layoutDesktop === LAYOUTS.row) { - const { accessory, ariaLabelIndicator, ariaLabelNext, ariaLabelPrev } = props; + const { + accessory, + ariaLabelIndicator, + ariaLabelNext, + ariaLabelPrev, + } = props; return ( { it('should show expand accessory', () => { const cards = Array(12).map(() => test); - const { asFragment } = render( + render( { , ); - expect(asFragment()).toMatchSnapshot(); + expect(screen.getByRole('button')).toHaveClass( + 'bpk-button bpk-button--link', + ); }); - it('should show button accessory', () => { + it('should show button accessory and handle onButtonClick', async () => { const cards = Array(12).map(() => test); - const { asFragment } = render( + const onButtonClick = jest.fn(); + render( {cards} , ); + await userEvent.click(screen.getByRole('button')); - expect(asFragment()).toMatchSnapshot(); + expect(screen.getByRole('button')).toHaveClass( + 'bpk-button bpk-button--primary', + ); + expect(onButtonClick).toHaveBeenCalled(); }); }); diff --git a/packages/bpk-component-card-list/src/BpkCardListGrid/__snapshots__/BpkCardListGrid-test.tsx.snap b/packages/bpk-component-card-list/src/BpkCardListGrid/__snapshots__/BpkCardListGrid-test.tsx.snap deleted file mode 100644 index 97b7bb4cdf..0000000000 --- a/packages/bpk-component-card-list/src/BpkCardListGrid/__snapshots__/BpkCardListGrid-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkCardListGrid should show button accessory 1`] = ` - -
- - -`; - -exports[`BpkCardListGrid should show expand accessory 1`] = ` - -
- - -`; diff --git a/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail-test.tsx b/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail-test.tsx index 952f7f4455..90e1bfbbb9 100644 --- a/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail-test.tsx +++ b/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail-test.tsx @@ -27,7 +27,9 @@ describe('BpkCardListRail', () => { {mockCards(3)}, ); - expect(container).toMatchSnapshot(); + expect(container.firstChild).toHaveClass( + 'bpk-card-list--rail_scrollContainer', + ); expect( container.getElementsByClassName('bpk-card-list--rail_card'), ).toHaveLength(3); diff --git a/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail.tsx b/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail.tsx index def918aa11..e5ab591820 100644 --- a/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail.tsx +++ b/packages/bpk-component-card-list/src/BpkCardListRail/BpkCardListRail.tsx @@ -18,6 +18,7 @@ */ import type { ReactElement } from 'react'; +// @ts-ignore import BpkMobileScrollContainer from '../../../bpk-component-mobile-scroll-container'; import { cssModules } from '../../../bpk-react-utils'; diff --git a/packages/bpk-component-card-list/src/BpkCardListRail/__snapshots__/BpkCardListRail-test.tsx.snap b/packages/bpk-component-card-list/src/BpkCardListRail/__snapshots__/BpkCardListRail-test.tsx.snap deleted file mode 100644 index 309912f4b5..0000000000 --- a/packages/bpk-component-card-list/src/BpkCardListRail/__snapshots__/BpkCardListRail-test.tsx.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkCardListRail should render cards correctly in the MobileScrollContainer 1`] = ` -
-
-
-
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-
-`; diff --git a/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow-test.tsx b/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow-test.tsx index 6c752def2f..91ace3df1d 100644 --- a/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow-test.tsx +++ b/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow-test.tsx @@ -78,7 +78,6 @@ describe('BpkCardListRow', () => { {mockCards(7)}, ); - expect(container).toMatchSnapshot(); expect( container.getElementsByClassName( 'bpk-card-list-row__card bpk-card-list-row__card-padding', diff --git a/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow.tsx b/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow.tsx index 1dde8e169c..c959c9adbb 100644 --- a/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow.tsx +++ b/packages/bpk-component-card-list/src/BpkCardListRow/BpkCardListRow.tsx @@ -26,6 +26,7 @@ import { import debounce from 'lodash/debounce'; +// @ts-ignore import BpkPageIndicator from '../../../bpk-component-page-indicator'; import { cssModules, isRTL } from '../../../bpk-react-utils'; diff --git a/packages/bpk-component-card-list/src/BpkCardListRow/__snapshots__/BpkCardListRow-test.tsx.snap b/packages/bpk-component-card-list/src/BpkCardListRow/__snapshots__/BpkCardListRow-test.tsx.snap deleted file mode 100644 index db6557a67f..0000000000 --- a/packages/bpk-component-card-list/src/BpkCardListRow/__snapshots__/BpkCardListRow-test.tsx.snap +++ /dev/null @@ -1,172 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkCardListRow should render cards and accessory correctly for 7 cards 1`] = ` -
-
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-`; diff --git a/packages/bpk-component-card-list/src/BpkCardListStack/BpkCardListStack-test.tsx b/packages/bpk-component-card-list/src/BpkCardListStack/BpkCardListStack-test.tsx index 6e79331287..dc088c37a4 100644 --- a/packages/bpk-component-card-list/src/BpkCardListStack/BpkCardListStack-test.tsx +++ b/packages/bpk-component-card-list/src/BpkCardListStack/BpkCardListStack-test.tsx @@ -15,7 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import BpkCard from '../../../bpk-component-card'; @@ -24,7 +25,7 @@ import BpkCardListStack from './BpkCardListStack'; describe('BpkCardListStack', () => { it('should show expand accessory', () => { const cards = Array(12).map(() => test); - const { asFragment } = render( + render( { , ); - expect(asFragment()).toMatchSnapshot(); + expect(screen.getByRole('button')).toHaveClass( + 'bpk-button bpk-button--link', + ); }); - it('should show button accessory', () => { + it('should show button accessory', async () => { const cards = Array(12).map(() => test); - const { asFragment } = render( + const onButtonClick = jest.fn(); + render( {cards} , ); + await userEvent.click(screen.getByRole('button')); - expect(asFragment()).toMatchSnapshot(); - }) + expect(screen.getByRole('button')).toHaveClass( + 'bpk-button bpk-button--primary', + ); + expect(onButtonClick).toHaveBeenCalled(); + }); }); diff --git a/packages/bpk-component-card-list/src/BpkCardListStack/__snapshots__/BpkCardListStack-test.tsx.snap b/packages/bpk-component-card-list/src/BpkCardListStack/__snapshots__/BpkCardListStack-test.tsx.snap deleted file mode 100644 index 29be608b30..0000000000 --- a/packages/bpk-component-card-list/src/BpkCardListStack/__snapshots__/BpkCardListStack-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkCardListStack should show button accessory 1`] = ` - -
- - -`; - -exports[`BpkCardListStack should show expand accessory 1`] = ` - -
- - -`; diff --git a/packages/bpk-component-card-list/src/BpkExpand/BpkExpand-test.tsx b/packages/bpk-component-card-list/src/BpkExpand/BpkExpand-test.tsx index 250eeb0b3f..ecab51b17b 100644 --- a/packages/bpk-component-card-list/src/BpkExpand/BpkExpand-test.tsx +++ b/packages/bpk-component-card-list/src/BpkExpand/BpkExpand-test.tsx @@ -15,14 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import BpkExpand from './BpkExpand'; describe('BpkExpand', () => { it('should render correctly', () => { - const { asFragment } = render( + render( { , ); - expect(asFragment()).toMatchSnapshot(); + expect(screen.getByRole('button')).toHaveAttribute('type', 'button'); }); it('should call showContent function when collapsed and button is clicked', async () => { @@ -41,7 +41,7 @@ describe('BpkExpand', () => { const setCollapsed = jest.fn(); const showContent = jest.fn(); - const { asFragment, getByTestId } = render( + render( { , ); - expect(asFragment()).toMatchSnapshot(); - - await userEvent.click(getByTestId('button')); + await userEvent.click(screen.getByTestId('button')); expect(showContent).toHaveBeenCalled(); expect(setCollapsed).toHaveBeenCalledWith(false); @@ -65,7 +63,7 @@ describe('BpkExpand', () => { const setCollapsed = jest.fn(); const showContent = jest.fn(); - const { asFragment, getByTestId } = render( + render( { , ); - expect(asFragment()).toMatchSnapshot(); - - await userEvent.click(getByTestId('button')); + await userEvent.click(screen.getByTestId('button')); expect(hideContent).toHaveBeenCalled(); expect(setCollapsed).toHaveBeenCalledWith(true); diff --git a/packages/bpk-component-card-list/src/BpkExpand/__snapshots__/BpkExpand-test.tsx.snap b/packages/bpk-component-card-list/src/BpkExpand/__snapshots__/BpkExpand-test.tsx.snap deleted file mode 100644 index aba98943eb..0000000000 --- a/packages/bpk-component-card-list/src/BpkExpand/__snapshots__/BpkExpand-test.tsx.snap +++ /dev/null @@ -1,85 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkExpand should call hideContent function when not collapsed and button is clicked 1`] = ` - - - -`; - -exports[`BpkExpand should call showContent function when collapsed and button is clicked 1`] = ` - - - -`; - -exports[`BpkExpand should render correctly 1`] = ` - - - -`; diff --git a/packages/bpk-component-card-list/src/__snapshots__/BpkCardList-test.tsx.snap b/packages/bpk-component-card-list/src/__snapshots__/BpkCardList-test.tsx.snap deleted file mode 100644 index c5532bdeab..0000000000 --- a/packages/bpk-component-card-list/src/__snapshots__/BpkCardList-test.tsx.snap +++ /dev/null @@ -1,1087 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BpkCardList should render correctly with grid, rail and button accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with grid, rail and expand accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with grid, rail and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
- - -
-
-
-
-`; - -exports[`BpkCardList should render correctly with grid, stack and button accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with grid, stack and expand accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with grid, stack and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
- - -
-
-
-
-`; - -exports[`BpkCardList should render correctly with header, grid, rail and expand accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with header, grid, rail and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
-
-
-
-`; - -exports[`BpkCardList should render correctly with header, grid, stack and expand accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
- -
-
-
-`; - -exports[`BpkCardList should render correctly with header, grid, stack and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
- - -
-
-
-
-`; - -exports[`BpkCardList should render correctly with header, row, rail and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
-
-
- -
-
- -
-
-
-
-
-
-`; - -exports[`BpkCardList should render correctly with header, row, rail and pagination accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-`; - -exports[`BpkCardList should render correctly with header, row, stack and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
- -
-
-
-
-
- -
-
- -
-
-
-
-
-
-`; - -exports[`BpkCardList should render correctly with row, rail and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-`; - -exports[`BpkCardList should render correctly with row, rail and pagination accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-`; - -exports[`BpkCardList should render correctly with row, stack and no accessory 1`] = ` - -
-
-
-

- Title -

- - - Description - - -
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-`; diff --git a/packages/bpk-component-carousel/src/BpkCarousel.tsx b/packages/bpk-component-carousel/src/BpkCarousel.tsx index 9d7b6378ea..53de929a8a 100644 --- a/packages/bpk-component-carousel/src/BpkCarousel.tsx +++ b/packages/bpk-component-carousel/src/BpkCarousel.tsx @@ -18,6 +18,7 @@ import { useRef, useState } from 'react'; +// @ts-ignore import BpkPageIndicator, { VARIANT } from '../../bpk-component-page-indicator'; import { cssModules } from '../../bpk-react-utils'; diff --git a/packages/bpk-component-chip-group/src/BpkMultiSelectChipGroup.tsx b/packages/bpk-component-chip-group/src/BpkMultiSelectChipGroup.tsx index 70837707d5..9d640f3ac6 100644 --- a/packages/bpk-component-chip-group/src/BpkMultiSelectChipGroup.tsx +++ b/packages/bpk-component-chip-group/src/BpkMultiSelectChipGroup.tsx @@ -21,6 +21,7 @@ import { useRef } from 'react'; import BpkBreakpoint, { BREAKPOINTS } from '../../bpk-component-breakpoint'; import BpkSelectableChip, { BpkDismissibleChip, BpkIconChip, BpkDropdownChip, CHIP_TYPES } from '../../bpk-component-chip'; import FilterIconSm from '../../bpk-component-icon/sm/filter'; +// @ts-ignore import BpkMobileScrollContainer from '../../bpk-component-mobile-scroll-container'; import BpkText, { TEXT_STYLES } from '../../bpk-component-text/src/BpkText'; import { cssModules } from '../../bpk-react-utils';