Created
June 27, 2012 15:53
-
-
Save mjschranz/3004993 to your computer and use it in GitHub Desktop.
Page Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment