diff options
Diffstat (limited to 'apps/system/test/unit/mock_modal_dialog.js')
-rw-r--r-- | apps/system/test/unit/mock_modal_dialog.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/system/test/unit/mock_modal_dialog.js b/apps/system/test/unit/mock_modal_dialog.js new file mode 100644 index 0000000..beb452e --- /dev/null +++ b/apps/system/test/unit/mock_modal_dialog.js @@ -0,0 +1,34 @@ +var MockModalDialog = { + + mMethods: [ + 'alert' + ], + + mPopulate: function mmd_mPopulate() { + this.mMethods.forEach(function(methodName) { + this[methodName] = function mmd_method() { + this.mMethodCalled(methodName, Array.slice(arguments)); + }; + }, this); + }, + + init: function mmd_init() { + this.mMethods.forEach(function(methodName) { + this[methodName].mWasCalled = false; + this[methodName].mArgs = null; + }, this); + }, + + mMethodCalled: function mmd_mMethodCalled(name, args) { + this[name].mWasCalled = true; + this[name].mArgs = args; + }, + + mTeardown: function mmd_mTeardown() { + this.init(); + } +}; + +MockModalDialog.mPopulate(); + + |