Skip to content

Commit

Permalink
Element: Add test for serialization with nested providers
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Aug 13, 2018
1 parent b6b7da7 commit e32503e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/element/src/test/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,28 @@ describe( 'renderElement()', () => {
expect( result ).toBe( '1st provided|2nd provided|default' );
} );

it( 'renders proper value through Context API when nested providers', () => {
const { Consumer, Provider } = createContext( {
value: 'default',
} );

const result = renderElement(
<Provider value={ { value: 'outer provided' } }>
<Provider value={ { value: 'inner provided' } }>
<Consumer>
{ ( context ) => context.value }
</Consumer>
</Provider>
{ '|' }
<Consumer>
{ ( context ) => context.value }
</Consumer>
</Provider>
);

expect( result ).toBe( 'inner provided|outer provided' );
} );

it( 'renders RawHTML as its unescaped children', () => {
const result = renderElement( <RawHTML>{ '<img/>' }</RawHTML> );

Expand Down

0 comments on commit e32503e

Please sign in to comment.