We used many global functions to handle tests when they should be imported like other libraries in our application. This also gets us closer to the way Ember CLI prefers our tests to be laid out.
25 lines
766 B
JavaScript
25 lines
766 B
JavaScript
import { moduleForComponent } from "ember-qunit";
|
|
import componentTest from "discourse/tests/helpers/component-test";
|
|
|
|
moduleForComponent("iframed-html", { integration: true });
|
|
|
|
componentTest("appends the html into the iframe", {
|
|
template: `{{iframed-html html="<h1 id='find-me'>hello</h1>" className='this-is-an-iframe'}}`,
|
|
|
|
async test(assert) {
|
|
const iframe = find("iframe.this-is-an-iframe");
|
|
assert.equal(iframe.length, 1, "inserts an iframe");
|
|
|
|
assert.ok(
|
|
iframe[0].classList.contains("this-is-an-iframe"),
|
|
"Adds className to the iframes classList"
|
|
);
|
|
|
|
assert.equal(
|
|
iframe[0].contentWindow.document.body.querySelectorAll("#find-me").length,
|
|
1,
|
|
"inserts the passed in html into the iframe"
|
|
);
|
|
},
|
|
});
|