Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

issue 463: add unit test #464

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/bugs/issue463.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import postscribe from '../../src/postscribe';
const $ = require('jquery');

describe('bugs', () => {
it('issue 463: dynamically created iframe with a text', done => {
let text = 'body text';
let script = `<script>
var iframe = document.createElement('iframe');
iframe['id'] = 'iframeid';
iframe['frameBorder'] = 0;
document.getElementsByTagName('body')[0].appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write('<!DOCTYPE html><head></head><body>${text}</body></html>');
iframe.contentWindow.document.close();
<\/script>`;

const options = {};
options.done = () => {
setTimeout( function() {
let iframe_text = $('#iframeid').contents().find('body').html();
expect(iframe_text).to.be.equal(text);
done();
}, 4);
};

jQuery( document ).ready( function() {
postscribe( document.body, script, options);
});

});
});