Created
June 2, 2011 03:36
-
-
Save bsatrom/1003886 to your computer and use it in GitHub Desktop.
Starting point for mocking window.external methods for Pinned Site functionality
This file contains 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
//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'); | |
}); |
This file contains 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
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