-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from pixiv/toshusai/feat-add-component-as
Feat: Added `componentAs` to the `Button`.
- Loading branch information
Showing
5 changed files
with
98 additions
and
42 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
11 changes: 11 additions & 0 deletions
11
packages/react/src/components/Button/__snapshots__/index.test.tsx.snap
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Button /> componentAs props are passed to the data-as attribute 1`] = ` | ||
<a | ||
className="charcoal-button" | ||
data-as="componentAs" | ||
data-full-width={true} | ||
href="/" | ||
target="_blank" | ||
/> | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'jest-styled-components' | ||
|
||
import renderer from 'react-test-renderer' | ||
import Button from '.' | ||
|
||
function Link({ | ||
as, | ||
children, | ||
...props | ||
}: { as: string; children: React.ReactNode } & React.ComponentProps<'a'>) { | ||
return ( | ||
<a {...props} data-as={as}> | ||
{children} | ||
</a> | ||
) | ||
} | ||
|
||
describe('<Button />', () => { | ||
test('componentAs props are passed to the data-as attribute', () => { | ||
expect( | ||
renderer.create( | ||
<Button | ||
href="/" | ||
target="_blank" | ||
fullWidth | ||
as={Link} | ||
componentAs="componentAs" | ||
/> | ||
) | ||
).toMatchSnapshot() | ||
}) | ||
}) |
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