diff options
Diffstat (limited to 'std/types/tests')
-rw-r--r-- | std/types/tests/react-dom_mock.js | 9 | ||||
-rw-r--r-- | std/types/tests/react-dom_test.tsx | 20 | ||||
-rw-r--r-- | std/types/tests/react_mock.js | 9 | ||||
-rw-r--r-- | std/types/tests/react_test.tsx | 23 |
4 files changed, 61 insertions, 0 deletions
diff --git a/std/types/tests/react-dom_mock.js b/std/types/tests/react-dom_mock.js new file mode 100644 index 000000000..68b4137ba --- /dev/null +++ b/std/types/tests/react-dom_mock.js @@ -0,0 +1,9 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +const ReactDOM = { + render(element) { + return JSON.stringify(element); + } +}; + +export default ReactDOM; diff --git a/std/types/tests/react-dom_test.tsx b/std/types/tests/react-dom_test.tsx new file mode 100644 index 000000000..738227b65 --- /dev/null +++ b/std/types/tests/react-dom_test.tsx @@ -0,0 +1,20 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +// @deno-types="../react.d.ts" +import React from "./react_mock.js"; +// @deno-types="../react-dom.d.ts" +import ReactDOM from "./react-dom_mock.js"; + +import { assertEquals } from "../../testing/asserts.ts"; + +const { test } = Deno; + +test({ + name: "ReactDOM is typed to render", + fn() { + assertEquals( + ReactDOM.render(<div />, null), + '"{\\"type\\":\\"div\\",\\"props\\":null,\\"children\\":[]}"' + ); + } +}); diff --git a/std/types/tests/react_mock.js b/std/types/tests/react_mock.js new file mode 100644 index 000000000..93faa6c9b --- /dev/null +++ b/std/types/tests/react_mock.js @@ -0,0 +1,9 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +const React = { + createElement(type, props, ...children) { + return JSON.stringify({ type, props, children }); + } +}; + +export default React; diff --git a/std/types/tests/react_test.tsx b/std/types/tests/react_test.tsx new file mode 100644 index 000000000..f9ffc471a --- /dev/null +++ b/std/types/tests/react_test.tsx @@ -0,0 +1,23 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +// @deno-types="../react.d.ts" +import React from "./react_mock.js"; +import { assertEquals } from "../../testing/asserts.ts"; + +const { test } = Deno; + +test({ + name: "JSX can be rendered", + fn() { + class Component { + render() { + return <div></div>; + } + } + + assertEquals( + new Component().render(), + `{"type":"div","props":null,"children":[]}` + ); + } +}); |