Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins authored and alshdavid committed Sep 16, 2024
1 parent 38060aa commit cadcc54
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/browser/getOwnerDocument.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'preact';
import { createElement, render } from 'preact';
import { setupScratch, teardown } from '../_util/helpers';

/** @jsx createElement */
Expand Down Expand Up @@ -28,13 +28,20 @@ describe('parentDom.ownerDocument', () => {

iframeDoc.close();

let spy = sinon.spy(iframeDoc, 'createTextNode');
let rootTextSpy = sinon.spy(document, 'createTextNode');
let rootElementSpy = sinon.spy(document, 'createElement');

let iframeTextSpy = sinon.spy(iframeDoc, 'createTextNode');
let iframeElementSpy = sinon.spy(iframeDoc, 'createElement');

let iframeRootNode = iframeDoc.querySelector('div');

render('Hello', iframeRootNode);
render(<span>Hello</span>, iframeRootNode);

expect(spy).to.be.called;
expect(rootTextSpy).not.to.be.called;
expect(rootElementSpy).not.to.be.called;
expect(iframeTextSpy).to.be.called;
expect(iframeElementSpy).to.be.called;

expect(iframeRootNode.textContent).to.be.equal('Hello');
expect(iframeRootNode.firstChild.ownerDocument).to.be.equal(iframeDoc);
Expand Down

0 comments on commit cadcc54

Please sign in to comment.