/*global text,expect,ok,module,notEqual,Butter,test,window*/ (function (window, document, Butter, undefined) { require( [ "../src/core/page", "../src/core/config", "../src/dependencies" ], function( Page, Config, Dependencies ) { var _config = Config.parse( '{ "test": "derp" }' ), _loader = Dependencies( _config ), _page = new Page( _loader, _config ); test( "Page - scrape media target and media elements", 3, function() { var scrapedPage; scrapedPage = _page.scrape(); ok( scrapedPage, "Scrape Returned an Object" ); equal( scrapedPage.media.length, 2, "Scrape retrieved two media elements" ); equal( scrapedPage.target.length, 2, "Scrape retrieved two target elements" ); }); test( "Page - getHTML generation", function() { var $document = window.document, focument = (function(doc){ // load iframe into current doc var iframe = document.createElement( "iframe" ); iframe.onload = function() { // iframe doc for butter page faking return iframe.contentDocument; } iframe.src = "../../templates/test.html"; document.body.appendChild( iframe ); }($document)); function swapDoc(){ window.document = focument; } function restoreDoc(){ window.document = $document; } swapDoc(); console.log(window.document.documentElement.innerHTML); var html = _page.getHTML(); console.log(html); restoreDoc(); }); }); })(window, document, Butter);