diff --git a/src/__tests__/cleanup.js b/src/__tests__/cleanup.js index 9f17c722..649a34e8 100644 --- a/src/__tests__/cleanup.js +++ b/src/__tests__/cleanup.js @@ -27,6 +27,46 @@ test('cleanup does not error when an element is not a child', () => { cleanup() }) +describe('container is the document', () => { + let documentElement + beforeEach(() => { + documentElement = document.documentElement + }) + + afterEach(() => { + // React 18 removes the `` element when unmounting a root rendered into `document` + if (document.documentElement === null) { + document.appendChild(documentElement) + } + }) + + test('cleanup does not error when the container is the document', () => { + render( + +
+ + + , + {container: document}, + ) + + cleanup() + }) + + test('cleanup does not error when hydrating the document', () => { + render( + // eslint-disable-next-line jsx-a11y/html-has-lang -- matches the existing document + +