Commit 7d35c2e 1 parent 677dc77 commit 7d35c2e Copy full SHA for 7d35c2e
File tree 2 files changed +18
-4
lines changed
src/components/messages/error-message
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import Text from '../../typography/text' ;
4
+ import filterDataAttributes from '../../../utils/filter-data-attributes' ;
4
5
5
6
const ErrorMessage = props => (
6
- < Text . Detail tone = "negative" > { props . children } </ Text . Detail >
7
+ < Text . Detail tone = "negative" { ...filterDataAttributes ( props ) } >
8
+ { props . children }
9
+ </ Text . Detail >
7
10
) ;
8
11
ErrorMessage . displayName = 'ErrorMessage' ;
9
12
ErrorMessage . propTypes = {
Original file line number Diff line number Diff line change @@ -2,8 +2,19 @@ import React from 'react';
2
2
import { render } from '../../../test-utils' ;
3
3
import ErrorMessage from './error-message' ;
4
4
5
- it ( 'should render children' , ( ) => {
6
- const { container } = render ( < ErrorMessage > Some error message</ ErrorMessage > ) ;
5
+ describe ( 'ErrorMessage' , ( ) => {
6
+ it ( 'should render children' , ( ) => {
7
+ const { container } = render (
8
+ < ErrorMessage > Some error message</ ErrorMessage >
9
+ ) ;
7
10
8
- expect ( container ) . toHaveTextContent ( 'Some error message' ) ;
11
+ expect ( container ) . toHaveTextContent ( 'Some error message' ) ;
12
+ } ) ;
13
+
14
+ it ( 'should forward data-attributes' , ( ) => {
15
+ const { container } = render (
16
+ < ErrorMessage data-foo = "bar" > Some error message</ ErrorMessage >
17
+ ) ;
18
+ expect ( container . querySelector ( '[data-foo="bar"]' ) ) . toBeInTheDocument ( ) ;
19
+ } ) ;
9
20
} ) ;
You can’t perform that action at this time.
0 commit comments