@@ -20,6 +20,40 @@ describe('#createX', () => {
2020 font-size: 10px;
2121 ` )
2222 } )
23+
24+ it ( 'avoids passing system props to HTML element' , ( ) => {
25+ const x = createX < FontSizeProps < Theme > > ( fontSize )
26+ const { container } = render ( < x . div fontSize = { 10 } /> )
27+ expect ( container . firstChild ) . not . toHaveAttribute ( 'fontSize' )
28+ } )
29+
30+ it ( 'passes HTML attrs to HTML element' , ( ) => {
31+ const x = createX < FontSizeProps < Theme > > ( fontSize )
32+ const { container } = render ( < x . div role = "presentation" /> )
33+ expect ( container . firstChild ) . toHaveAttribute ( 'role' , 'presentation' )
34+ } )
35+
36+ it ( 'avoids passing system props to "as" component' , ( ) => {
37+ const Component = props => < div { ...props } />
38+ const x = createX < FontSizeProps < Theme > > ( fontSize )
39+ const { container } = render ( < x . div as = { Component } fontSize = { 10 } /> )
40+ expect ( container . firstChild ) . not . toHaveAttribute ( 'fontSize' )
41+ } )
42+
43+ it ( 'passes non-system props to "as" component' , ( ) => {
44+ const Component = ( { asdf, ...props } ) => < div { ...props } > { asdf } </ div >
45+ const x = createX < FontSizeProps < Theme > > ( fontSize )
46+ const { container } = render ( < x . div as = { Component } asdf = "boo!" /> )
47+ expect ( container . firstChild ) . toHaveTextContent ( 'boo!' )
48+ } )
49+
50+ // skip because this depends on unreleased styled-components 5.2.4 or 6
51+ it . skip ( 'avoids passing non-HTML attrs to HTML element' , ( ) => {
52+ const x = createX < FontSizeProps < Theme > > ( fontSize )
53+ const { container } = render ( < x . div asdf = "boo!" /> )
54+ expect ( container . firstChild ) . not . toHaveAttribute ( 'asdf' )
55+ } )
56+
2357} )
2458
2559describe ( '#x.extend' , ( ) => {
0 commit comments