Skip to content

Instantly share code, notes, and snippets.

@bsatrom
Created June 2, 2011 03:36
Show Gist options
  • Save bsatrom/1003886 to your computer and use it in GitHub Desktop.
Save bsatrom/1003886 to your computer and use it in GitHub Desktop.
Starting point for mocking window.external methods for Pinned Site functionality
//sample usage, with qUnit and pinify
//<script src="js/jquery-1.6.min.js"></script>
//<script src="js/jquery.pinify.js"></script>
//<script src="js/qunit.js"></script>
module('', {
teardown: function() {
windowMocks.resetWindow();
}
});
test('isPinned() when site is pinned should return true', function() {
windowMocks.mockMsIsSiteMode();
equals($.pinify.isPinned(), true, 'isPinned should be true');
});
var windowMocks = {};
windowMocks.window = window;
//Should be called by user after each test
windowMocks.resetWindow = function() {
window = windowMocks.window;
};
windowMocks.mockWindowExternal = function() {
window = {};
window.external = function() {};
};
windowMocks.mockMsIsSiteMode = function(value) {
this.mockWindowExternal();
window.external.msIsSiteMode = function() {
return value || true;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment