feat: provide Fragment component

Adds a new Fragment component that provides the same functionality as
React.Fragment. See issue #9 for details.

closes issue #9
This commit is contained in:
M. George Hansen 2020-06-04 11:25:34 -07:00
parent b112dc2d97
commit da241efb59
Signed by: mgeorgehansen
SSH key fingerprint: SHA256:JlIGiQLPyQ2RHTH3a2oVlb20Xkh9Glr8DUF4YTXHJxM
4 changed files with 43 additions and 4 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { Component, createElement } from "../../dist";
import { Component, createElement, Fragment } from "../../dist";
import { renderPage } from "../../dist/render";
import { testSuite } from "../lib";
@ -103,4 +103,18 @@ testSuite("renderPage", ({ test, expect }) => {
"<!DOCTYPE html><html>There are <div>3 lights</div>!</html>"
);
});
test("renders fragment children only", () => {
const html = renderPage(
<html>
<Fragment>
<div>test of</div>
<div>fragments</div>
</Fragment>
</html>
);
expect(html).toEqual(
"<!DOCTYPE html><html><div>test of</div><div>fragments</div></html>"
);
});
});