-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Components: Adding Slot rendering unit tests
- Loading branch information
1 parent
c3ac841
commit 1fb6853
Showing
2 changed files
with
69 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { mount } from 'enzyme'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Slot from '../slot'; | ||
import Fill from '../fill'; | ||
import Provider from '../provider'; | ||
|
||
describe( 'Slot', () => { | ||
it( 'should render empty Fills', () => { | ||
const element = mount( | ||
<Provider> | ||
<Slot name="chicken" /> | ||
<Fill name="chicken" /> | ||
</Provider> | ||
); | ||
|
||
expect( element.find( 'Slot > div' ).html() ).toBe( '<div></div>' ); | ||
} ); | ||
|
||
it( 'should render a string Fill', () => { | ||
const element = mount( | ||
<Provider> | ||
<Slot name="chicken" /> | ||
<Fill name="chicken"> | ||
content | ||
</Fill> | ||
</Provider> | ||
); | ||
|
||
expect( element.find( 'Slot > div' ).html() ).toBe( '<div>content</div>' ); | ||
} ); | ||
|
||
it( 'should render a Fill containing an element', () => { | ||
const element = mount( | ||
<Provider> | ||
<Slot name="chicken" /> | ||
<Fill name="chicken"> | ||
<span /> | ||
</Fill> | ||
</Provider> | ||
); | ||
|
||
expect( element.find( 'Slot > div' ).html() ).toBe( '<div><span></span></div>' ); | ||
} ); | ||
|
||
it( 'should render a Fill containing an array', () => { | ||
const element = mount( | ||
<Provider> | ||
<Slot name="chicken" /> | ||
<Fill name="chicken"> | ||
{ [ <span key="1" />, <div key="2" />, 'text' ] } | ||
</Fill> | ||
</Provider> | ||
); | ||
|
||
expect( element.find( 'Slot > div' ).html() ).toBe( '<div><span></span><div></div>text</div>' ); | ||
} ); | ||
} ); |