summaryrefslogtreecommitdiff
path: root/preact/compat/test/browser/unmountComponentAtNode.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'preact/compat/test/browser/unmountComponentAtNode.test.js')
-rw-r--r--preact/compat/test/browser/unmountComponentAtNode.test.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/preact/compat/test/browser/unmountComponentAtNode.test.js b/preact/compat/test/browser/unmountComponentAtNode.test.js
new file mode 100644
index 0000000..bcf87df
--- /dev/null
+++ b/preact/compat/test/browser/unmountComponentAtNode.test.js
@@ -0,0 +1,28 @@
+import React, { createElement, unmountComponentAtNode } from 'preact/compat';
+import { setupScratch, teardown } from '../../../test/_util/helpers';
+
+describe('unmountComponentAtNode', () => {
+ /** @type {HTMLDivElement} */
+ let scratch;
+
+ beforeEach(() => {
+ scratch = setupScratch();
+ });
+
+ afterEach(() => {
+ teardown(scratch);
+ });
+
+ it('should unmount a root node', () => {
+ const App = () => <div>foo</div>;
+ React.render(<App />, scratch);
+
+ expect(unmountComponentAtNode(scratch)).to.equal(true);
+ expect(scratch.innerHTML).to.equal('');
+ });
+
+ it('should do nothing if root is not mounted', () => {
+ expect(unmountComponentAtNode(scratch)).to.equal(false);
+ expect(scratch.innerHTML).to.equal('');
+ });
+});