@@ -6,13 +6,16 @@ import Adapter from 'enzyme-adapter-react-16';
66configure ( { adapter : new Adapter ( ) } ) ;
77
88test ( 'Renders raw HTML in a wrapper element' , ( ) => {
9- let wrapper = mount (
9+ const wrapper = mount (
1010 < RichContent sanitizedRawHtml = "<h1 id='o-no'>Raw!!!</h1>" />
1111 ) ;
1212 expect ( wrapper . html ( ) ) . toEqual (
1313 '<span class="peregrine-raw-html"><h1 id="o-no">Raw!!!</h1></span>'
1414 ) ;
15- wrapper = mount (
15+ } ) ;
16+
17+ test ( 'Favors React.Element children over raw HTML when both are present' , ( ) => {
18+ const wrapper = mount (
1619 < RichContent sanitizedRawHtml = "<h1 id='o-no'><span>Raw!!!</span></h1>" >
1720 { null }
1821 </ RichContent >
@@ -23,7 +26,7 @@ test('Renders raw HTML in a wrapper element', () => {
2326} ) ;
2427
2528test ( 'Takes DOM properties for a custom wrapper element' , ( ) => {
26- let wrapper = mount (
29+ const wrapper = mount (
2730 < RichContent
2831 sanitizedRawHtml = "<h1 id='o-no'>Raw!!!</h1>"
2932 wrapperTag = "article"
@@ -32,7 +35,10 @@ test('Takes DOM properties for a custom wrapper element', () => {
3235 expect ( wrapper . html ( ) ) . toEqual (
3336 '<article class="peregrine-raw-html"><h1 id="o-no">Raw!!!</h1></article>'
3437 ) ;
35- wrapper = mount (
38+ } ) ;
39+
40+ test ( 'Custom wrapper element still wraps raw HTML when null children present' , ( ) => {
41+ const wrapper = mount (
3642 < RichContent
3743 sanitizedRawHtml = "<h1 id='o-no'>Raw!!!</h1>"
3844 wrapperTag = "div"
@@ -52,7 +58,7 @@ test('Takes DOM properties for a custom wrapper element', () => {
5258} ) ;
5359
5460test ( 'Replaces raw HTML with live children' , ( ) => {
55- let wrapper = mount (
61+ const wrapper = mount (
5662 < RichContent sanitizedRawHtml = "<h1 id='o-no'>Raw!!!</h1>" >
5763 < p className = "woah" style = { { marginTop : '10px' } } >
5864 test inner text
@@ -62,8 +68,10 @@ test('Replaces raw HTML with live children', () => {
6268 expect ( wrapper . html ( ) ) . toEqual (
6369 '<p class="woah" style="margin-top: 10px;">test inner text</p>'
6470 ) ;
71+ } ) ;
6572
66- wrapper = mount (
73+ test ( 'Replaces raw HTML with live children and does not wrap with custom element' , ( ) => {
74+ const wrapper = mount (
6775 < RichContent
6876 wrapperTag = "i"
6977 sanitizedRawHtml = "<h1 id='o-no'>Raw!!!</h1>"
0 commit comments