a_mock 1.0.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/AUTHORS +1 -1
  2. package/and/newBinaryAnd.js +19 -19
  3. package/and/newBinaryAndSpec/test.js +67 -67
  4. package/and/newMonadicAnd.js +19 -19
  5. package/and/newMonadicAndSpec/test.js +45 -45
  6. package/and.js +11 -11
  7. package/andSpec/test.js +35 -35
  8. package/andSpec/testIntegration.js +24 -24
  9. package/eventEmitter/add.js +5 -5
  10. package/eventEmitter/addSpec/test.js +22 -22
  11. package/eventEmitter/emitterContext.js +7 -7
  12. package/eventEmitter/emitterContextSpec/test.js +12 -12
  13. package/eventEmitter/remove.js +11 -11
  14. package/eventEmitter/removeSpec/test.js +27 -27
  15. package/eventEmitter/tryAdd.js +7 -7
  16. package/eventEmitter/tryAddSpec/test.js +43 -43
  17. package/eventEmitter/tryRemove.js +7 -7
  18. package/eventEmitter/tryRemoveSpec/test.js +43 -43
  19. package/eventEmitter.js +42 -42
  20. package/eventEmitterSpec/test.js +142 -142
  21. package/expectRequire.js +20 -20
  22. package/expectRequireSpec/test.js +67 -67
  23. package/index.d.ts +96 -0
  24. package/index.js +9 -10
  25. package/mock/mockContext.js +9 -9
  26. package/mock/mockContextSpec/test.js +30 -30
  27. package/mock/mockFuncProperties.js +16 -16
  28. package/mock/mockFuncPropertiesSpec/test.js +67 -67
  29. package/mock/objectMock.js +23 -23
  30. package/mock/objectMockSpec/test.js +123 -123
  31. package/mock/propertyMock.js +13 -13
  32. package/mock/propertyMockSpec/test.js +36 -36
  33. package/mock/throwUnexpectedArguments.js +13 -13
  34. package/mock/throwUnexpectedArgumentsSpec/test.js +35 -35
  35. package/mock.js +19 -19
  36. package/mockSpec/test.js +65 -65
  37. package/mockSpec/testIntegration.js +102 -102
  38. package/newMutableAnd.js +18 -18
  39. package/newMutableAndSpec/test.js +48 -48
  40. package/newObject.js +4 -4
  41. package/newThen.js +111 -111
  42. package/newThenSpec/test.js +11 -11
  43. package/newThenSpec/testExecute.js +80 -80
  44. package/newThenSpec/testNoCallback.js +57 -57
  45. package/newThenSpec/testPreReject.js +51 -51
  46. package/newThenSpec/testPreRejectAndThrow.js +50 -50
  47. package/newThenSpec/testPreResolve.js +49 -49
  48. package/newThenSpec/testPreResolveAndThrow.js +48 -48
  49. package/newThenSpec/testReject.js +56 -56
  50. package/newThenSpec/testRejectAndThrow.js +56 -56
  51. package/newThenSpec/testResolve.js +56 -56
  52. package/newThenSpec/testResolveAndThrow.js +54 -54
  53. package/newThenSpec/testResolveWithFailingPromise.js +65 -65
  54. package/newThenSpec/testResolveWithPromise.js +65 -65
  55. package/newTrueNTimesThenFalse.js +29 -29
  56. package/newTrueNTimesThenFalseSpec/test.js +59 -59
  57. package/newTrueOnceThenFalse.js +21 -21
  58. package/newTrueOnceThenFalseSpec/test.js +25 -25
  59. package/package.json +14 -13
  60. package/partialMock/execute.js +18 -18
  61. package/partialMock/executeSpec/test.js +84 -84
  62. package/partialMock/expect.js +13 -13
  63. package/partialMock/expectAnything.js +51 -51
  64. package/partialMock/expectAnythingSpec/test.js +167 -167
  65. package/partialMock/expectArray.js +11 -11
  66. package/partialMock/expectArraySpec/test.js +36 -36
  67. package/partialMock/expectCore.js +70 -70
  68. package/partialMock/expectCoreSpec/test.js +241 -241
  69. package/partialMock/expectEmpty.js +47 -47
  70. package/partialMock/expectEmptySpec/test.js +194 -194
  71. package/partialMock/expectSpec/test.js +45 -45
  72. package/partialMock/fallbackWrapper/getStackTrace.js +13 -13
  73. package/partialMock/hasSameArgument/isEqualArg.js +68 -68
  74. package/partialMock/hasSameArgument/isEqualArgSpec/test.js +283 -283
  75. package/partialMock/ignore.js +7 -7
  76. package/partialMock/ignoreSpec/test.js +30 -30
  77. package/partialMock/mockContext/reset.js +14 -14
  78. package/partialMock/mockContext/resetSpec/test.js +42 -42
  79. package/partialMock/negotiateDecrementExpectCount.js +5 -5
  80. package/partialMock/negotiateDecrementExpectCountSpec/test.js +31 -31
  81. package/partialMock/negotiateEnd.js +10 -10
  82. package/partialMock/negotiateEndSpec/test.js +64 -64
  83. package/partialMock/negotiateIncrementExpectCount.js +5 -5
  84. package/partialMock/negotiateIncrementExpectCountSpec/test.js +31 -31
  85. package/partialMock/newExecute.js +21 -21
  86. package/partialMock/newExecuteSpec/test.js +61 -61
  87. package/partialMock/newFallbackWrapper.js +30 -30
  88. package/partialMock/newFallbackWrapperSpec/test.js +70 -70
  89. package/partialMock/newFallbackWrapperSpec/testWithMockError.js +59 -59
  90. package/partialMock/newFallbackWrapperSpec/testWithOtherError.js +48 -48
  91. package/partialMock/newHasArgument.js +9 -9
  92. package/partialMock/newHasArgumentSpec/test.js +36 -36
  93. package/partialMock/newHasEqualArgumentArray.js +23 -23
  94. package/partialMock/newHasEqualArgumentArraySpec/test.js +59 -59
  95. package/partialMock/newHasNoMoreArguments.js +15 -15
  96. package/partialMock/newHasNoMoreArgumentsSpec/test.js +64 -64
  97. package/partialMock/newHasSameArgument.js +11 -11
  98. package/partialMock/newHasSameArgumentSpec/test.js +80 -80
  99. package/partialMock/newMockContext.js +12 -12
  100. package/partialMock/newMockContextSpec/test.js +36 -36
  101. package/partialMock/newThrow.js +6 -6
  102. package/partialMock/newThrowSpec/test.js +20 -20
  103. package/partialMock/return.js +24 -24
  104. package/partialMock/returnSpec/test.js +106 -106
  105. package/partialMock/setExecute.js +15 -15
  106. package/partialMock/setExecuteSpec/test.js +87 -87
  107. package/partialMock/simple/expectRequire.js +12 -12
  108. package/partialMock/simple/expectRequireSpec/test.js +41 -41
  109. package/partialMock/simple/newMock/throwUnexpectedArguments.js +9 -9
  110. package/partialMock/simple/newMock/throwUnexpectedArgumentsSpec/test.js +23 -23
  111. package/partialMock/simple/newMock.js +10 -10
  112. package/partialMock/simple/newMockSpec/test.js +28 -28
  113. package/partialMock/simple/newPartialMock.js +124 -124
  114. package/partialMock/simple/newPartialMockSpec/test.js +141 -141
  115. package/partialMock/simple/newPartialMockSpec/testRepeat.js +63 -63
  116. package/partialMock/simple/newPartialMockSpec/testWithMultiArgs.js +54 -54
  117. package/partialMock/simple/newPartialMockSpec/testWithSingleArg.js +116 -116
  118. package/partialMock/simple/newRequireMock.js +12 -12
  119. package/partialMock/simple/newRequireMockSpec/test.js +39 -39
  120. package/partialMock/verify.js +7 -7
  121. package/partialMock/verifySpec/test.js +37 -37
  122. package/partialMock.js +70 -70
  123. package/partialMockSpec/test.js +235 -235
  124. package/partialMockSpec/testIntegration.js +568 -568
  125. package/promise.js +10 -10
  126. package/requireMock.js +14 -14
  127. package/requireMockSpec/test.js +45 -45
  128. package/strictMock.js +10 -10
  129. package/strictMockSpec/test.js +28 -28
  130. package/test.js +16 -16
  131. package/util.js +7 -1
  132. package/.npmignore +0 -1
@@ -1,241 +1,241 @@
1
- var assert = require('assert');
2
- var test = require('../../test');
3
- var newMock = require('../simple/newMock');
4
- var newRequireMock = require('../simple/newRequireMock');
5
-
6
- var expect = newRequireMock('./expect');
7
- var expectAnything = newRequireMock('./expectAnything');
8
- var ignore = newRequireMock('./ignore');
9
- var expectArray = newRequireMock('./expectArray');
10
- var _return = newRequireMock('./return');
11
- var newWhenCalledEmitter = newRequireMock('../eventEmitter');
12
- var newThrow = newRequireMock('./newThrow');
13
- var newThen = newRequireMock('../newThen');
14
- var sut = require('../expectCore');
15
-
16
-
17
- (function(){
18
- console.log('expectCore');
19
- var mockContext = {};
20
- var compositeAreCorrectArguments = newMock();
21
- var whenCalledEmitter = {} ;
22
- var hasCorrectArgument = {};
23
- var index = 1;
24
- var didAdd;
25
-
26
- stubWhenCalledEmitter();
27
- stubMockContext();
28
- stubCompositeAreCorrectArguments();
29
-
30
- function stubWhenCalledEmitter() {
31
- newWhenCalledEmitter.expect().return(whenCalledEmitter);
32
- }
33
-
34
- function stubMockContext() {
35
- mockContext.compositeAreCorrectArguments = compositeAreCorrectArguments;
36
- }
37
-
38
- function stubCompositeAreCorrectArguments() {
39
- var add = newMock();
40
- add.expect(hasCorrectArgument).whenCalled(onAdd).return(null);
41
- compositeAreCorrectArguments.add = add;
42
- }
43
-
44
- function onAdd() {
45
- didAdd = true;
46
- }
47
-
48
- var sut2 = sut(hasCorrectArgument,index,mockContext);
49
-
50
- test('it should set mockContext.NumberOfArgs to index+1',function() {
51
- assert.equal(mockContext.numberOfArgs,index+1);
52
- });
53
-
54
- test('it should add areSameArgument to compositeAreCorrectArguments',function() {
55
- assert.ok(didAdd);
56
- });
57
-
58
- test('it should set mockContext.whenCalledEmitter',function() {
59
- assert.equal(mockContext.whenCalledEmitter,whenCalledEmitter);
60
- });
61
-
62
- (function() {
63
- console.log('expect');
64
- var expected = {};
65
- var arg = {};
66
- var arg2 = {};
67
- expect.expect(index+1).expect(mockContext).expect(arg).expect(arg2).return(expected);
68
- var returned = sut2.expect(arg,arg2);
69
-
70
- test('should return expected',function() {
71
- assert.equal(returned,expected)
72
- });
73
- })();
74
-
75
- (function() {
76
- console.log('expectAnything');
77
- var expected = {};
78
- var arg = {};
79
- expectAnything.expect(index+1).expect(mockContext).return(expected);
80
- var returned = sut2.expectAnything();
81
-
82
- test('should return expected',function() {
83
- assert.equal(returned,expected)
84
- });
85
- })();
86
-
87
- (function() {
88
- console.log('ignore');
89
- var expected = {};
90
- var arg = {};
91
- ignore.expect(index+1).expect(mockContext).return(expected);
92
- var returned = sut2.ignore();
93
-
94
- test('should return expected',function() {
95
- assert.equal(returned,expected)
96
- });
97
- })();
98
-
99
- (function() {
100
- console.log('expectArray');
101
- var expected = {};
102
- var arg = {};
103
- expectArray.expect(index+1).expect(mockContext).expect(arg).return(expected);
104
- var returned = sut2.expectArray(arg);
105
-
106
- test('should return expected',function() {
107
- assert.equal(returned,expected)
108
- });
109
- })();
110
-
111
- (function() {
112
- console.log('return');
113
- var expected = {};
114
- var arg = {};
115
- _return.expect(arg).expect(index+1).expect(mockContext).return(expected);
116
- var returned = sut2.return(arg);
117
-
118
- test('should return expected',function() {
119
- assert.equal(returned,expected)
120
- });
121
- })();
122
-
123
- (function() {
124
- console.log('whenCalled');
125
- var callback = {};
126
- var expected;
127
- var add = newMock();
128
- whenCalledEmitter.add = add;
129
- var didAddCallback;
130
- add.expect(callback).whenCalled(onAddCallback).return();
131
-
132
- function onAddCallback() {
133
- didAddCallback = true;
134
- }
135
-
136
- mockContext.whenCalledEmitter = whenCalledEmitter;
137
-
138
- var returned = sut2.whenCalled(callback);
139
-
140
- test('should add callback to whenCalledEmitter',function() {
141
- assert.ok(didAddCallback)
142
- });
143
-
144
- test('should return self',function() {
145
- assert.equal(returned,sut2);
146
- });
147
- })();
148
-
149
- (function() {
150
- console.log('throw');
151
- var error = {};
152
- var _throw = {};
153
- var expected = {};
154
- newThrow.expect(error).return(_throw);
155
- sut2.whenCalled = newMock();
156
- sut2.whenCalled.expect(_throw).return(expected);
157
- var returned = sut2.throw(error);
158
-
159
- test('should return expected',function() {
160
- assert.equal(expected,returned);
161
- });
162
- })();
163
-
164
-
165
- (function() {
166
- console.log('repeat');
167
- var expected = {};
168
- var times = 2;
169
- var returnContext = {};
170
- var repeatMock = newMock();
171
- _return.expectAnything().expect(index+1).expect(mockContext).whenCalled(onReturn).return(returnContext);
172
-
173
- function onReturn(returnValue) {
174
- if (returnValue !== undefined)
175
- throw new Error('unexpected argument');
176
- }
177
-
178
- returnContext.repeat = repeatMock;
179
- repeatMock.expect(times).return(expected);
180
-
181
- var returned = sut2.repeat(times);
182
-
183
- test('should return expected',function() {
184
- assert.equal(returned,expected)
185
- });
186
- })();
187
-
188
- (function() {
189
- console.log('repeatAny');
190
- var expected = {};
191
- var returnContext = {};
192
- var repeatMock = newMock();
193
- _return.expectAnything().expect(index+1).expect(mockContext).whenCalled(onReturn).return(returnContext);
194
-
195
- function onReturn(returnValue) {
196
- if (returnValue !== undefined)
197
- throw new Error('unexpected argument');
198
- }
199
-
200
- returnContext.repeatAny = repeatMock;
201
- repeatMock.expect().return(expected);
202
-
203
- var returned = sut2.repeatAny();
204
-
205
- test('should return expected',function() {
206
- assert.equal(returned,expected)
207
- });
208
- })();
209
-
210
- (function() {
211
- console.log('resolve');
212
- var expected = {};
213
- var arg = {};
214
- promise = {};
215
- newThen.resolve = newMock();
216
- newThen.resolve.expect(arg).return(promise);
217
- _return.expect(promise).expect(index+1).expect(mockContext).return(expected);
218
- var returned = sut2.resolve(arg);
219
-
220
- test('should return expected as promise',function() {
221
- assert.equal(returned,expected)
222
- });
223
- })();
224
-
225
- (function() {
226
- console.log('reject');
227
- var expected = {};
228
- var arg = {};
229
- promise = {};
230
- newThen.reject = newMock();
231
- newThen.reject.expect(arg).return(promise);
232
- _return.expect(promise).expect(index+1).expect(mockContext).return(expected);
233
- var returned = sut2.reject(arg);
234
-
235
- test('should return expected as promise',function() {
236
- assert.equal(returned,expected)
237
- });
238
- })();
239
-
240
-
241
- })();
1
+ var assert = require('assert');
2
+ var test = require('../../test');
3
+ var newMock = require('../simple/newMock');
4
+ var newRequireMock = require('../simple/newRequireMock');
5
+
6
+ var expect = newRequireMock('./expect');
7
+ var expectAnything = newRequireMock('./expectAnything');
8
+ var ignore = newRequireMock('./ignore');
9
+ var expectArray = newRequireMock('./expectArray');
10
+ var _return = newRequireMock('./return');
11
+ var newWhenCalledEmitter = newRequireMock('../eventEmitter');
12
+ var newThrow = newRequireMock('./newThrow');
13
+ var newThen = newRequireMock('../newThen');
14
+ var sut = require('../expectCore');
15
+
16
+
17
+ (function(){
18
+ console.log('expectCore');
19
+ var mockContext = {};
20
+ var compositeAreCorrectArguments = newMock();
21
+ var whenCalledEmitter = {} ;
22
+ var hasCorrectArgument = {};
23
+ var index = 1;
24
+ var didAdd;
25
+
26
+ stubWhenCalledEmitter();
27
+ stubMockContext();
28
+ stubCompositeAreCorrectArguments();
29
+
30
+ function stubWhenCalledEmitter() {
31
+ newWhenCalledEmitter.expect().return(whenCalledEmitter);
32
+ }
33
+
34
+ function stubMockContext() {
35
+ mockContext.compositeAreCorrectArguments = compositeAreCorrectArguments;
36
+ }
37
+
38
+ function stubCompositeAreCorrectArguments() {
39
+ var add = newMock();
40
+ add.expect(hasCorrectArgument).whenCalled(onAdd).return(null);
41
+ compositeAreCorrectArguments.add = add;
42
+ }
43
+
44
+ function onAdd() {
45
+ didAdd = true;
46
+ }
47
+
48
+ var sut2 = sut(hasCorrectArgument,index,mockContext);
49
+
50
+ test('it should set mockContext.NumberOfArgs to index+1',function() {
51
+ assert.equal(mockContext.numberOfArgs,index+1);
52
+ });
53
+
54
+ test('it should add areSameArgument to compositeAreCorrectArguments',function() {
55
+ assert.ok(didAdd);
56
+ });
57
+
58
+ test('it should set mockContext.whenCalledEmitter',function() {
59
+ assert.equal(mockContext.whenCalledEmitter,whenCalledEmitter);
60
+ });
61
+
62
+ (function() {
63
+ console.log('expect');
64
+ var expected = {};
65
+ var arg = {};
66
+ var arg2 = {};
67
+ expect.expect(index+1).expect(mockContext).expect(arg).expect(arg2).return(expected);
68
+ var returned = sut2.expect(arg,arg2);
69
+
70
+ test('should return expected',function() {
71
+ assert.equal(returned,expected)
72
+ });
73
+ })();
74
+
75
+ (function() {
76
+ console.log('expectAnything');
77
+ var expected = {};
78
+ var arg = {};
79
+ expectAnything.expect(index+1).expect(mockContext).return(expected);
80
+ var returned = sut2.expectAnything();
81
+
82
+ test('should return expected',function() {
83
+ assert.equal(returned,expected)
84
+ });
85
+ })();
86
+
87
+ (function() {
88
+ console.log('ignore');
89
+ var expected = {};
90
+ var arg = {};
91
+ ignore.expect(index+1).expect(mockContext).return(expected);
92
+ var returned = sut2.ignore();
93
+
94
+ test('should return expected',function() {
95
+ assert.equal(returned,expected)
96
+ });
97
+ })();
98
+
99
+ (function() {
100
+ console.log('expectArray');
101
+ var expected = {};
102
+ var arg = {};
103
+ expectArray.expect(index+1).expect(mockContext).expect(arg).return(expected);
104
+ var returned = sut2.expectArray(arg);
105
+
106
+ test('should return expected',function() {
107
+ assert.equal(returned,expected)
108
+ });
109
+ })();
110
+
111
+ (function() {
112
+ console.log('return');
113
+ var expected = {};
114
+ var arg = {};
115
+ _return.expect(arg).expect(index+1).expect(mockContext).return(expected);
116
+ var returned = sut2.return(arg);
117
+
118
+ test('should return expected',function() {
119
+ assert.equal(returned,expected)
120
+ });
121
+ })();
122
+
123
+ (function() {
124
+ console.log('whenCalled');
125
+ var callback = {};
126
+ var expected;
127
+ var add = newMock();
128
+ whenCalledEmitter.add = add;
129
+ var didAddCallback;
130
+ add.expect(callback).whenCalled(onAddCallback).return();
131
+
132
+ function onAddCallback() {
133
+ didAddCallback = true;
134
+ }
135
+
136
+ mockContext.whenCalledEmitter = whenCalledEmitter;
137
+
138
+ var returned = sut2.whenCalled(callback);
139
+
140
+ test('should add callback to whenCalledEmitter',function() {
141
+ assert.ok(didAddCallback)
142
+ });
143
+
144
+ test('should return self',function() {
145
+ assert.equal(returned,sut2);
146
+ });
147
+ })();
148
+
149
+ (function() {
150
+ console.log('throw');
151
+ var error = {};
152
+ var _throw = {};
153
+ var expected = {};
154
+ newThrow.expect(error).return(_throw);
155
+ sut2.whenCalled = newMock();
156
+ sut2.whenCalled.expect(_throw).return(expected);
157
+ var returned = sut2.throw(error);
158
+
159
+ test('should return expected',function() {
160
+ assert.equal(expected,returned);
161
+ });
162
+ })();
163
+
164
+
165
+ (function() {
166
+ console.log('repeat');
167
+ var expected = {};
168
+ var times = 2;
169
+ var returnContext = {};
170
+ var repeatMock = newMock();
171
+ _return.expectAnything().expect(index+1).expect(mockContext).whenCalled(onReturn).return(returnContext);
172
+
173
+ function onReturn(returnValue) {
174
+ if (returnValue !== undefined)
175
+ throw new Error('unexpected argument');
176
+ }
177
+
178
+ returnContext.repeat = repeatMock;
179
+ repeatMock.expect(times).return(expected);
180
+
181
+ var returned = sut2.repeat(times);
182
+
183
+ test('should return expected',function() {
184
+ assert.equal(returned,expected)
185
+ });
186
+ })();
187
+
188
+ (function() {
189
+ console.log('repeatAny');
190
+ var expected = {};
191
+ var returnContext = {};
192
+ var repeatMock = newMock();
193
+ _return.expectAnything().expect(index+1).expect(mockContext).whenCalled(onReturn).return(returnContext);
194
+
195
+ function onReturn(returnValue) {
196
+ if (returnValue !== undefined)
197
+ throw new Error('unexpected argument');
198
+ }
199
+
200
+ returnContext.repeatAny = repeatMock;
201
+ repeatMock.expect().return(expected);
202
+
203
+ var returned = sut2.repeatAny();
204
+
205
+ test('should return expected',function() {
206
+ assert.equal(returned,expected)
207
+ });
208
+ })();
209
+
210
+ (function() {
211
+ console.log('resolve');
212
+ var expected = {};
213
+ var arg = {};
214
+ promise = {};
215
+ newThen.resolve = newMock();
216
+ newThen.resolve.expect(arg).return(promise);
217
+ _return.expect(promise).expect(index+1).expect(mockContext).return(expected);
218
+ var returned = sut2.resolve(arg);
219
+
220
+ test('should return expected as promise',function() {
221
+ assert.equal(returned,expected)
222
+ });
223
+ })();
224
+
225
+ (function() {
226
+ console.log('reject');
227
+ var expected = {};
228
+ var arg = {};
229
+ promise = {};
230
+ newThen.reject = newMock();
231
+ newThen.reject.expect(arg).return(promise);
232
+ _return.expect(promise).expect(index+1).expect(mockContext).return(expected);
233
+ var returned = sut2.reject(arg);
234
+
235
+ test('should return expected as promise',function() {
236
+ assert.equal(returned,expected)
237
+ });
238
+ })();
239
+
240
+
241
+ })();
@@ -1,48 +1,48 @@
1
- var newThrow = require('./newThrow');
2
-
3
- function expectEmpty(mockContext) {
4
- var _return = require('./return');
5
- mockContext.whenCalledEmitter = require('../eventEmitter')();
6
- var hasCorrectArgument = require('./newHasNoMoreArguments')(0, mockContext);
7
- var newThen = require('../newThen');
8
-
9
- var c = {};
10
- mockContext.compositeAreCorrectArguments.add(hasCorrectArgument);
11
- mockContext.numberOfArgs = 0;
12
-
13
- c.return = function(arg) {
14
- return _return(arg,0,mockContext);
15
- };
16
-
17
- c.whenCalled = function(callback) {
18
- mockContext.whenCalledEmitter.add(callback);
19
- return c;
20
- };
21
-
22
- c.throw = function(error) {
23
- var _throw = newThrow(error);
24
- return c.whenCalled(_throw);
25
- };
26
-
27
- c.repeat = function(times) {
28
- return _return(undefined,0,mockContext).repeat(times);
29
- };
30
-
31
- c.repeatAny = function() {
32
- return _return(undefined,0,mockContext).repeatAny();
33
- };
34
-
35
- c.resolve = function (value) {
36
- var promise = newThen.resolve(value);
37
- return c.return(promise);
38
- };
39
-
40
- c.reject = function (value) {
41
- var promise = newThen.reject(value);
42
- return c.return(promise);
43
- };
44
-
45
- return c;
46
- }
47
-
1
+ var newThrow = require('./newThrow');
2
+
3
+ function expectEmpty(mockContext) {
4
+ var _return = require('./return');
5
+ mockContext.whenCalledEmitter = require('../eventEmitter')();
6
+ var hasCorrectArgument = require('./newHasNoMoreArguments')(0, mockContext);
7
+ var newThen = require('../newThen');
8
+
9
+ var c = {};
10
+ mockContext.compositeAreCorrectArguments.add(hasCorrectArgument);
11
+ mockContext.numberOfArgs = 0;
12
+
13
+ c.return = function(arg) {
14
+ return _return(arg,0,mockContext);
15
+ };
16
+
17
+ c.whenCalled = function(callback) {
18
+ mockContext.whenCalledEmitter.add(callback);
19
+ return c;
20
+ };
21
+
22
+ c.throw = function(error) {
23
+ var _throw = newThrow(error);
24
+ return c.whenCalled(_throw);
25
+ };
26
+
27
+ c.repeat = function(times) {
28
+ return _return(undefined,0,mockContext).repeat(times);
29
+ };
30
+
31
+ c.repeatAny = function() {
32
+ return _return(undefined,0,mockContext).repeatAny();
33
+ };
34
+
35
+ c.resolve = function (value) {
36
+ var promise = newThen.resolve(value);
37
+ return c.return(promise);
38
+ };
39
+
40
+ c.reject = function (value) {
41
+ var promise = newThen.reject(value);
42
+ return c.return(promise);
43
+ };
44
+
45
+ return c;
46
+ }
47
+
48
48
  module.exports = expectEmpty;