Skip to content

Commit

Permalink
Don't display Guide's page control if there is only one page
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Mar 8, 2021
1 parent c8c6573 commit 46ff3f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/components/src/guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ export default function Guide( {
<div className="components-guide__page">
{ pages[ currentPage ].image }

<PageControl
currentPage={ currentPage }
numberOfPages={ pages.length }
setCurrentPage={ setCurrentPage }
/>
{ pages.length > 1 && (
<PageControl
currentPage={ currentPage }
numberOfPages={ pages.length }
setCurrentPage={ setCurrentPage }
/>
) }

{ pages[ currentPage ].content }

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/guide/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ describe( 'Guide', () => {
).toHaveLength( 1 );
} );

it( "doesn't display the page control if there is only one page", () => {
const wrapper = shallow(
<Guide pages={ [ { content: <p>Page 1</p> } ] } />
);
expect( wrapper.find( PageControl ).exists() ).toBeFalsy();
} );

it( 'calls onFinish when the finish button is clicked', () => {
const onFinish = jest.fn();
const wrapper = shallow(
Expand Down

0 comments on commit 46ff3f4

Please sign in to comment.