1
1
const assert = require ( 'assert' ) ;
2
2
const React = require ( 'react' ) ;
3
- const parse = require ( '../ ' ) ;
3
+ const parse = require ( '..' ) ;
4
4
const { data, render } = require ( './helpers/' ) ;
5
5
6
6
describe ( 'html-to-react' , ( ) => {
7
+ describe ( 'exports' , ( ) => {
8
+ it ( 'has default ES Module' , ( ) => {
9
+ assert . strictEqual ( parse . default , parse ) ;
10
+ } ) ;
11
+
12
+ it ( 'has domToReact' , ( ) => {
13
+ assert . strictEqual ( parse . domToReact , require ( '../lib/dom-to-react' ) ) ;
14
+ } ) ;
15
+
16
+ it ( 'contains htmlToDOM' , ( ) => {
17
+ assert . strictEqual ( parse . htmlToDOM , require ( 'html-dom-parser' ) ) ;
18
+ } ) ;
19
+ } ) ;
20
+
7
21
describe ( 'parser' , ( ) => {
8
22
[ undefined , null , { } , [ ] , 42 ] . forEach ( value => {
9
23
it ( `throws an error if first argument is ${ value } ` , ( ) => {
@@ -13,10 +27,6 @@ describe('html-to-react', () => {
13
27
} ) ;
14
28
} ) ;
15
29
16
- it ( 'has default ES Module defined' , ( ) => {
17
- assert . strictEqual ( parse . default , parse ) ;
18
- } ) ;
19
-
20
30
it ( 'returns string if it cannot be parsed as HTML' , ( ) => {
21
31
assert . strictEqual ( parse ( 'foo' ) , 'foo' ) ;
22
32
} ) ;
@@ -77,7 +87,7 @@ describe('html-to-react', () => {
77
87
78
88
describe ( 'options' , ( ) => {
79
89
describe ( 'replace' , ( ) => {
80
- it ( 'overrides the element if replace is valid ' , ( ) => {
90
+ it ( 'overrides the element if a valid React element is returned ' , ( ) => {
81
91
const html = data . html . complex ;
82
92
const reactElement = parse ( html , {
83
93
replace : node => {
@@ -92,7 +102,7 @@ describe('html-to-react', () => {
92
102
) ;
93
103
} ) ;
94
104
95
- it ( 'does not override the element if replace is invalid ' , ( ) => {
105
+ it ( 'does not override the element if an invalid React element is returned ' , ( ) => {
96
106
const html = data . html . complex ;
97
107
const reactElement = parse ( html , {
98
108
replace : node => {
@@ -115,9 +125,3 @@ describe('html-to-react', () => {
115
125
} ) ;
116
126
} ) ;
117
127
} ) ;
118
-
119
- describe ( 'dom-to-react' , ( ) => {
120
- it ( 'exports domToReact' , ( ) => {
121
- assert . strictEqual ( parse . domToReact , require ( '../lib/dom-to-react' ) ) ;
122
- } ) ;
123
- } ) ;
0 commit comments