-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TextIntroduction -- Functional Dot Notation (#258)
Closes #260 ## Changes - TextIntroduction is now more composable with subcomponents - TextIntroduction story is updated (click on See Code) ## How to test this PR 1. View TextIntroduction Storybook story 2. Code Inspection 3. `yarn test TextIntroduction` ## Screenshots <img width="666" alt="Screenshot 2023-12-05 at 9 56 55 AM" src="https://github.com/cfpb/design-system-react/assets/13324863/6b4ee445-b690-49a7-ac4f-7ba706b188b3">
- Loading branch information
1 parent
307f291
commit 4e947c7
Showing
5 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,43 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { TextIntroduction } from '~/src/index'; | ||
import placeholders from './testHelpers'; | ||
import { cloneElement } from 'react'; | ||
import { List, ListItem, TextIntroduction } from '~/src/index'; | ||
import { | ||
callToAction, | ||
callToActionText, | ||
description, | ||
heading, | ||
placeholders, | ||
subheading | ||
} from './testHelpers'; | ||
|
||
describe('<TextIntroduction />', () => { | ||
it('renders all elements when provided', () => { | ||
render(<TextIntroduction {...placeholders} />); | ||
expect(screen.getByText(placeholders.heading)).toBeInTheDocument(); | ||
expect(screen.getByText(placeholders.subheading)).toBeInTheDocument(); | ||
expect(screen.getByText(placeholders.description)).toBeInTheDocument(); | ||
expect(screen.getByText(heading)).toBeInTheDocument(); | ||
expect(screen.getByText(subheading)).toBeInTheDocument(); | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
expect(screen.getByText('Call-to-action link')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('<TextIntroduction.Container />', () => { | ||
it('renders all elements when provided', () => { | ||
render( | ||
<TextIntroduction.Container> | ||
<TextIntroduction.Heading>{heading}</TextIntroduction.Heading> | ||
<TextIntroduction.Subheading>{subheading}</TextIntroduction.Subheading> | ||
<TextIntroduction.Description> | ||
{description} | ||
</TextIntroduction.Description> | ||
<List isLinks> | ||
<ListItem>{cloneElement(callToAction, { type: 'list' })}</ListItem> | ||
</List> | ||
</TextIntroduction.Container> | ||
); | ||
expect(screen.getByText(heading)).toBeInTheDocument(); | ||
expect(screen.getByText(subheading)).toBeInTheDocument(); | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
expect(screen.getByText(callToActionText)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import Link from '../Link/Link'; | ||
|
||
const subheading = | ||
export const heading = 'Heading 1'; | ||
|
||
export const subheading = | ||
'Lead paragraph lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'; | ||
|
||
const description = | ||
export const description = | ||
'Descriptive paragraph lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore.'; | ||
|
||
const callToAction = <Link href='/'>Call-to-action link</Link>; | ||
export const callToActionText = 'Call-to-action link'; | ||
|
||
export const callToAction = <Link href='/'>{callToActionText}</Link>; | ||
|
||
export const placeholders = { | ||
heading, | ||
subheading, | ||
description, | ||
callToAction | ||
}; | ||
|
||
export default { | ||
heading: 'Heading 1', | ||
heading, | ||
description, | ||
subheading, | ||
callToAction | ||
callToAction, | ||
callToActionText | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters