blob: 2c88a906d420e78c5f7fdedbb2eca458ff5a1819 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
var MockNotificationScreen = {
wasMethodCalled: {},
mockMethods: [
'incExternalNotifications',
'decExternalNotifications',
'updateStatusBarIcon'
],
mockPopulate: function mockPopulate() {
this.mockMethods.forEach(function(methodName) {
// we could probably put this method outside if we had a closure
this[methodName] = function mns_method() {
this.methodCalled(methodName);
};
}, this);
},
init: function mns_init() {
this.wasMethodCalled = {};
this.mockMethods.forEach(function(methodName) {
this[methodName].wasCalled = false;
}, this);
},
methodCalled: function mns_methodCalled(name) {
this.wasMethodCalled[name] =
this.wasMethodCalled[name] ? this.wasMethodCalled[name]++ : 1;
this[name].wasCalled = true;
},
mTeardown: function mns_mTeardown() {
this.init();
}
};
MockNotificationScreen.mockPopulate();
|