Skip to content

Commit 8dfbfe0

Browse files
test(html-to-react): tidy and organize tests in html-to-react.js
1 parent 57d27ff commit 8dfbfe0

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

test/html-to-react.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
const assert = require('assert');
22
const React = require('react');
3-
const parse = require('../');
3+
const parse = require('..');
44
const { data, render } = require('./helpers/');
55

66
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+
721
describe('parser', () => {
822
[undefined, null, {}, [], 42].forEach(value => {
923
it(`throws an error if first argument is ${value}`, () => {
@@ -13,10 +27,6 @@ describe('html-to-react', () => {
1327
});
1428
});
1529

16-
it('has default ES Module defined', () => {
17-
assert.strictEqual(parse.default, parse);
18-
});
19-
2030
it('returns string if it cannot be parsed as HTML', () => {
2131
assert.strictEqual(parse('foo'), 'foo');
2232
});
@@ -77,7 +87,7 @@ describe('html-to-react', () => {
7787

7888
describe('options', () => {
7989
describe('replace', () => {
80-
it('overrides the element if replace is valid', () => {
90+
it('overrides the element if a valid React element is returned', () => {
8191
const html = data.html.complex;
8292
const reactElement = parse(html, {
8393
replace: node => {
@@ -92,7 +102,7 @@ describe('html-to-react', () => {
92102
);
93103
});
94104

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', () => {
96106
const html = data.html.complex;
97107
const reactElement = parse(html, {
98108
replace: node => {
@@ -115,9 +125,3 @@ describe('html-to-react', () => {
115125
});
116126
});
117127
});
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

Comments
 (0)