Skip to content

Instantly share code, notes, and snippets.

@gcpantazis
Created October 23, 2012 17:57
Show Gist options
  • Save gcpantazis/3940361 to your computer and use it in GitHub Desktop.
Save gcpantazis/3940361 to your computer and use it in GitHub Desktop.
QUnit Module, Showing Iframe Loading / Destruction Calls.
// Tests : Example
var i, // testing iframe.
w; // testing iframe's window object.
module("Backbone Routers", {
setup: function() {
// Async, hold tests until iframe loads.
stop();
iframeLoad('/', function(iframe){
i = iframe;
w = i.contentWindow;
w.qunits = {};
// Initialize the app in the context of the iframe window.
w.require(['app-global'], function(AppGlobal) {
AppGlobal.init();
w.qunits.AppRouter = new AppGlobal.routers.AppRouter();
});
// Async, continue now that we're loaded and initialized.
start();
});
},
teardown: function() {
// Destroy iframe after every test.
iframeUnload(i);
}
});
test("AppRouter Exists", function() {
equal( typeof w.qunits.AppRouter, "object" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment