a_mock 1.0.5 → 2.0.0

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 (130) 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.js +9 -10
  24. package/mock/mockContext.js +9 -9
  25. package/mock/mockContextSpec/test.js +30 -30
  26. package/mock/mockFuncProperties.js +16 -16
  27. package/mock/mockFuncPropertiesSpec/test.js +67 -67
  28. package/mock/objectMock.js +23 -23
  29. package/mock/objectMockSpec/test.js +123 -123
  30. package/mock/propertyMock.js +13 -13
  31. package/mock/propertyMockSpec/test.js +36 -36
  32. package/mock/throwUnexpectedArguments.js +13 -13
  33. package/mock/throwUnexpectedArgumentsSpec/test.js +35 -35
  34. package/mock.js +19 -19
  35. package/mockSpec/test.js +65 -65
  36. package/mockSpec/testIntegration.js +102 -102
  37. package/newMutableAnd.js +18 -18
  38. package/newMutableAndSpec/test.js +48 -48
  39. package/newObject.js +4 -4
  40. package/newThen.js +111 -111
  41. package/newThenSpec/test.js +11 -11
  42. package/newThenSpec/testExecute.js +80 -80
  43. package/newThenSpec/testNoCallback.js +57 -57
  44. package/newThenSpec/testPreReject.js +51 -51
  45. package/newThenSpec/testPreRejectAndThrow.js +50 -50
  46. package/newThenSpec/testPreResolve.js +49 -49
  47. package/newThenSpec/testPreResolveAndThrow.js +48 -48
  48. package/newThenSpec/testReject.js +56 -56
  49. package/newThenSpec/testRejectAndThrow.js +56 -56
  50. package/newThenSpec/testResolve.js +56 -56
  51. package/newThenSpec/testResolveAndThrow.js +54 -54
  52. package/newThenSpec/testResolveWithFailingPromise.js +65 -65
  53. package/newThenSpec/testResolveWithPromise.js +65 -65
  54. package/newTrueNTimesThenFalse.js +29 -29
  55. package/newTrueNTimesThenFalseSpec/test.js +59 -59
  56. package/newTrueOnceThenFalse.js +21 -21
  57. package/newTrueOnceThenFalseSpec/test.js +25 -25
  58. package/package.json +13 -13
  59. package/partialMock/execute.js +18 -18
  60. package/partialMock/executeSpec/test.js +84 -84
  61. package/partialMock/expect.js +13 -13
  62. package/partialMock/expectAnything.js +51 -51
  63. package/partialMock/expectAnythingSpec/test.js +167 -167
  64. package/partialMock/expectArray.js +11 -11
  65. package/partialMock/expectArraySpec/test.js +36 -36
  66. package/partialMock/expectCore.js +70 -70
  67. package/partialMock/expectCoreSpec/test.js +241 -241
  68. package/partialMock/expectEmpty.js +47 -47
  69. package/partialMock/expectEmptySpec/test.js +194 -194
  70. package/partialMock/expectSpec/test.js +45 -45
  71. package/partialMock/fallbackWrapper/getStackTrace.js +13 -13
  72. package/partialMock/hasSameArgument/isEqualArg.js +68 -68
  73. package/partialMock/hasSameArgument/isEqualArgSpec/test.js +283 -283
  74. package/partialMock/ignore.js +7 -7
  75. package/partialMock/ignoreSpec/test.js +30 -30
  76. package/partialMock/mockContext/reset.js +14 -14
  77. package/partialMock/mockContext/resetSpec/test.js +42 -42
  78. package/partialMock/negotiateDecrementExpectCount.js +5 -5
  79. package/partialMock/negotiateDecrementExpectCountSpec/test.js +31 -31
  80. package/partialMock/negotiateEnd.js +10 -10
  81. package/partialMock/negotiateEndSpec/test.js +64 -64
  82. package/partialMock/negotiateIncrementExpectCount.js +5 -5
  83. package/partialMock/negotiateIncrementExpectCountSpec/test.js +31 -31
  84. package/partialMock/newExecute.js +21 -21
  85. package/partialMock/newExecuteSpec/test.js +61 -61
  86. package/partialMock/newFallbackWrapper.js +30 -30
  87. package/partialMock/newFallbackWrapperSpec/test.js +70 -70
  88. package/partialMock/newFallbackWrapperSpec/testWithMockError.js +59 -59
  89. package/partialMock/newFallbackWrapperSpec/testWithOtherError.js +48 -48
  90. package/partialMock/newHasArgument.js +9 -9
  91. package/partialMock/newHasArgumentSpec/test.js +36 -36
  92. package/partialMock/newHasEqualArgumentArray.js +23 -23
  93. package/partialMock/newHasEqualArgumentArraySpec/test.js +59 -59
  94. package/partialMock/newHasNoMoreArguments.js +15 -15
  95. package/partialMock/newHasNoMoreArgumentsSpec/test.js +64 -64
  96. package/partialMock/newHasSameArgument.js +11 -11
  97. package/partialMock/newHasSameArgumentSpec/test.js +80 -80
  98. package/partialMock/newMockContext.js +12 -12
  99. package/partialMock/newMockContextSpec/test.js +36 -36
  100. package/partialMock/newThrow.js +6 -6
  101. package/partialMock/newThrowSpec/test.js +20 -20
  102. package/partialMock/return.js +24 -24
  103. package/partialMock/returnSpec/test.js +106 -106
  104. package/partialMock/setExecute.js +15 -15
  105. package/partialMock/setExecuteSpec/test.js +87 -87
  106. package/partialMock/simple/expectRequire.js +12 -12
  107. package/partialMock/simple/expectRequireSpec/test.js +41 -41
  108. package/partialMock/simple/newMock/throwUnexpectedArguments.js +9 -9
  109. package/partialMock/simple/newMock/throwUnexpectedArgumentsSpec/test.js +23 -23
  110. package/partialMock/simple/newMock.js +10 -10
  111. package/partialMock/simple/newMockSpec/test.js +28 -28
  112. package/partialMock/simple/newPartialMock.js +124 -124
  113. package/partialMock/simple/newPartialMockSpec/test.js +141 -141
  114. package/partialMock/simple/newPartialMockSpec/testRepeat.js +63 -63
  115. package/partialMock/simple/newPartialMockSpec/testWithMultiArgs.js +54 -54
  116. package/partialMock/simple/newPartialMockSpec/testWithSingleArg.js +116 -116
  117. package/partialMock/simple/newRequireMock.js +12 -12
  118. package/partialMock/simple/newRequireMockSpec/test.js +39 -39
  119. package/partialMock/verify.js +7 -7
  120. package/partialMock/verifySpec/test.js +37 -37
  121. package/partialMock.js +70 -70
  122. package/partialMockSpec/test.js +235 -235
  123. package/partialMockSpec/testIntegration.js +568 -568
  124. package/promise.js +10 -10
  125. package/requireMock.js +14 -14
  126. package/requireMockSpec/test.js +45 -45
  127. package/strictMock.js +10 -10
  128. package/strictMockSpec/test.js +28 -28
  129. package/test.js +16 -16
  130. package/.npmignore +0 -1
@@ -1,235 +1,235 @@
1
- var test = require('../test');
2
- var assert = require('assert');
3
- var newMock = require('../partialMock/simple/newMock');
4
- var newRequireMock = require('../partialMock/simple/newRequireMock');
5
-
6
- var expectAnything = newRequireMock('./partialMock/expectAnything');
7
- var ignore = newRequireMock('./partialMock/ignore');
8
- var expect = newRequireMock('./partialMock/expect');
9
- var newMockContext = newRequireMock('./partialMock/newMockContext');
10
- var verify = newRequireMock('./partialMock/verify');
11
- var expectEmpty = newRequireMock('./partialMock/expectEmpty');
12
- var expectArray = newRequireMock('./partialMock/expectArray');
13
- var newMutableAnd = newRequireMock('./newMutableAnd')
14
- var negotiateEnd =newRequireMock('./partialMock/negotiateEnd');
15
- var newSut = require('../partialMock');
16
- var mutableAnd = {};
17
-
18
- function fallback() {}
19
-
20
- (function () {
21
- console.log('partialMock');
22
- var sut;
23
- var fallbackMock;
24
- var mockContext;
25
- function createSut() {
26
- stubMockContext();
27
-
28
- function stubMockContext() {
29
- mockContext = {};
30
- mockContext.reset = {};
31
- newMockContext.expect(fallback).return(mockContext);
32
- }
33
-
34
- sut = newSut(fallback);
35
- }
36
- createSut();
37
-
38
-
39
- test('reset points at mockContext.reset', function() {
40
- assert.equal(sut.reset, mockContext.reset);
41
- });
42
-
43
- (function() {
44
- console.log('when execute ');
45
- var arg = {};
46
- var expected = {};
47
- var execute = newMock();
48
- var didNegotiateEnd;
49
- execute.expect(arg).return(expected);
50
- mockContext.execute = execute;
51
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
52
- var returned = sut(arg);
53
-
54
- function onNegotiateEnd() {
55
- didNegotiateEnd = true;
56
- }
57
-
58
- test('should negotiateEnd', function() {
59
- assert.ok(didNegotiateEnd);
60
- });
61
-
62
- test('should return expected',function() {
63
- assert.equal(expected,returned);
64
- });
65
-
66
- })();
67
-
68
-
69
- (function() {
70
- console.log('when execute');
71
- var expected = {};
72
- mockContext.compositeAreCorrectArguments = null;
73
- var arg = 'arg';
74
- var arg2 = 'arg2';
75
- var didNegotiateEnd;
76
- newMutableAnd.expect().return(mutableAnd);
77
- expect.expect(0).expect(mockContext).expect(arg).expect(arg2).return(expected);
78
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
79
- var returned = sut.expect(arg,arg2);
80
-
81
- function onNegotiateEnd() {
82
- didNegotiateEnd = true;
83
- }
84
-
85
- test('it should negotiateEnd', function() {
86
- assert.ok(didNegotiateEnd);
87
- });
88
-
89
- test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
90
- assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
91
- });
92
-
93
- test('should return expected',function() {
94
- assert.equal(expected,returned)
95
- });
96
-
97
-
98
- })();
99
-
100
- (function() {
101
- console.log('when expect empty');
102
- var expected = {};
103
- var didNegotiateEnd;
104
- mockContext.compositeAreCorrectArguments = null;
105
- newMutableAnd.expect().return(mutableAnd);
106
- expectEmpty.expect(mockContext).return(expected);
107
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
108
-
109
- var returned = sut.expect();
110
-
111
- function onNegotiateEnd() {
112
- didNegotiateEnd = true;
113
- }
114
-
115
- test('should negotiateEnd', function() {
116
- assert.ok(didNegotiateEnd);
117
- });
118
-
119
- test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
120
- assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
121
- });
122
-
123
- test('should return expected',function() {
124
- assert.equal(expected,returned)
125
- });
126
-
127
- })();
128
-
129
-
130
- (function() {
131
- console.log('when expectAnything');
132
- var expected = {};
133
- var didNegotiateEnd;
134
- mockContext.compositeAreCorrectArguments = null;
135
- newMutableAnd.expect().return(mutableAnd);
136
- expectAnything.expect(0).expect(mockContext).return(expected);
137
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
138
- var returned = sut.expectAnything();
139
-
140
- function onNegotiateEnd() {
141
- didNegotiateEnd = true;
142
- }
143
-
144
- test('should negotiateEnd', function() {
145
- assert.ok(didNegotiateEnd);
146
- });
147
-
148
- test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
149
- assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
150
- });
151
-
152
- test('should return expected',function() {
153
- assert.equal(expected,returned)
154
- });
155
- })();
156
-
157
- (function() {
158
- console.log('when ignore');
159
- var expected = {};
160
- var didNegotiateEnd;
161
- mockContext.compositeAreCorrectArguments = null;
162
- newMutableAnd.expect().return(mutableAnd);
163
- ignore.expect(0).expect(mockContext).return(expected);
164
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
165
- var returned = sut.ignore();
166
-
167
- function onNegotiateEnd() {
168
- didNegotiateEnd = true;
169
- }
170
-
171
- test('should negotiateEnd', function() {
172
- assert.ok(didNegotiateEnd);
173
- });
174
-
175
- test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
176
- assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
177
- });
178
-
179
- test('should return expected',function() {
180
- assert.equal(expected,returned)
181
- });
182
- })();
183
-
184
- (function() {
185
- console.log('when verify');
186
- var expected = {};
187
- var didNegotiateEnd;
188
- verify.expect(mockContext).return(expected);
189
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
190
- var returned = sut.verify();
191
-
192
- function onNegotiateEnd() {
193
- didNegotiateEnd = true;
194
- }
195
-
196
- test('should negotiateEnd',function() {
197
- assert.ok(didNegotiateEnd);
198
- });
199
-
200
- test('should return expected',function() {
201
- assert.equal(expected,returned)
202
- });
203
- })();
204
-
205
- (function() {
206
- console.log('when expectArray');
207
- var expected = {};
208
- var didNegotiateEnd;
209
- mockContext.compositeAreCorrectArguments = null;
210
- var array = [];
211
- newMutableAnd.expect().return(mutableAnd);
212
- expectArray.expect(0).expect(mockContext).expect(array).return(expected);
213
- negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
214
- var returned = sut.expectArray(array);
215
-
216
- function onNegotiateEnd() {
217
- didNegotiateEnd = true;
218
- }
219
-
220
- test('should negotiateEnd', function() {
221
- assert.ok(didNegotiateEnd);
222
- });
223
-
224
-
225
- test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
226
- assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
227
- });
228
-
229
- test('should return expected',function() {
230
- assert.equal(expected,returned)
231
- });
232
- })();
233
-
234
-
235
- })();
1
+ var test = require('../test');
2
+ var assert = require('assert');
3
+ var newMock = require('../partialMock/simple/newMock');
4
+ var newRequireMock = require('../partialMock/simple/newRequireMock');
5
+
6
+ var expectAnything = newRequireMock('./partialMock/expectAnything');
7
+ var ignore = newRequireMock('./partialMock/ignore');
8
+ var expect = newRequireMock('./partialMock/expect');
9
+ var newMockContext = newRequireMock('./partialMock/newMockContext');
10
+ var verify = newRequireMock('./partialMock/verify');
11
+ var expectEmpty = newRequireMock('./partialMock/expectEmpty');
12
+ var expectArray = newRequireMock('./partialMock/expectArray');
13
+ var newMutableAnd = newRequireMock('./newMutableAnd')
14
+ var negotiateEnd =newRequireMock('./partialMock/negotiateEnd');
15
+ var newSut = require('../partialMock');
16
+ var mutableAnd = {};
17
+
18
+ function fallback() {}
19
+
20
+ (function () {
21
+ console.log('partialMock');
22
+ var sut;
23
+ var fallbackMock;
24
+ var mockContext;
25
+ function createSut() {
26
+ stubMockContext();
27
+
28
+ function stubMockContext() {
29
+ mockContext = {};
30
+ mockContext.reset = {};
31
+ newMockContext.expect(fallback).return(mockContext);
32
+ }
33
+
34
+ sut = newSut(fallback);
35
+ }
36
+ createSut();
37
+
38
+
39
+ test('reset points at mockContext.reset', function() {
40
+ assert.equal(sut.reset, mockContext.reset);
41
+ });
42
+
43
+ (function() {
44
+ console.log('when execute ');
45
+ var arg = {};
46
+ var expected = {};
47
+ var execute = newMock();
48
+ var didNegotiateEnd;
49
+ execute.expect(arg).return(expected);
50
+ mockContext.execute = execute;
51
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
52
+ var returned = sut(arg);
53
+
54
+ function onNegotiateEnd() {
55
+ didNegotiateEnd = true;
56
+ }
57
+
58
+ test('should negotiateEnd', function() {
59
+ assert.ok(didNegotiateEnd);
60
+ });
61
+
62
+ test('should return expected',function() {
63
+ assert.equal(expected,returned);
64
+ });
65
+
66
+ })();
67
+
68
+
69
+ (function() {
70
+ console.log('when execute');
71
+ var expected = {};
72
+ mockContext.compositeAreCorrectArguments = null;
73
+ var arg = 'arg';
74
+ var arg2 = 'arg2';
75
+ var didNegotiateEnd;
76
+ newMutableAnd.expect().return(mutableAnd);
77
+ expect.expect(0).expect(mockContext).expect(arg).expect(arg2).return(expected);
78
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
79
+ var returned = sut.expect(arg,arg2);
80
+
81
+ function onNegotiateEnd() {
82
+ didNegotiateEnd = true;
83
+ }
84
+
85
+ test('it should negotiateEnd', function() {
86
+ assert.ok(didNegotiateEnd);
87
+ });
88
+
89
+ test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
90
+ assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
91
+ });
92
+
93
+ test('should return expected',function() {
94
+ assert.equal(expected,returned)
95
+ });
96
+
97
+
98
+ })();
99
+
100
+ (function() {
101
+ console.log('when expect empty');
102
+ var expected = {};
103
+ var didNegotiateEnd;
104
+ mockContext.compositeAreCorrectArguments = null;
105
+ newMutableAnd.expect().return(mutableAnd);
106
+ expectEmpty.expect(mockContext).return(expected);
107
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
108
+
109
+ var returned = sut.expect();
110
+
111
+ function onNegotiateEnd() {
112
+ didNegotiateEnd = true;
113
+ }
114
+
115
+ test('should negotiateEnd', function() {
116
+ assert.ok(didNegotiateEnd);
117
+ });
118
+
119
+ test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
120
+ assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
121
+ });
122
+
123
+ test('should return expected',function() {
124
+ assert.equal(expected,returned)
125
+ });
126
+
127
+ })();
128
+
129
+
130
+ (function() {
131
+ console.log('when expectAnything');
132
+ var expected = {};
133
+ var didNegotiateEnd;
134
+ mockContext.compositeAreCorrectArguments = null;
135
+ newMutableAnd.expect().return(mutableAnd);
136
+ expectAnything.expect(0).expect(mockContext).return(expected);
137
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
138
+ var returned = sut.expectAnything();
139
+
140
+ function onNegotiateEnd() {
141
+ didNegotiateEnd = true;
142
+ }
143
+
144
+ test('should negotiateEnd', function() {
145
+ assert.ok(didNegotiateEnd);
146
+ });
147
+
148
+ test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
149
+ assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
150
+ });
151
+
152
+ test('should return expected',function() {
153
+ assert.equal(expected,returned)
154
+ });
155
+ })();
156
+
157
+ (function() {
158
+ console.log('when ignore');
159
+ var expected = {};
160
+ var didNegotiateEnd;
161
+ mockContext.compositeAreCorrectArguments = null;
162
+ newMutableAnd.expect().return(mutableAnd);
163
+ ignore.expect(0).expect(mockContext).return(expected);
164
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
165
+ var returned = sut.ignore();
166
+
167
+ function onNegotiateEnd() {
168
+ didNegotiateEnd = true;
169
+ }
170
+
171
+ test('should negotiateEnd', function() {
172
+ assert.ok(didNegotiateEnd);
173
+ });
174
+
175
+ test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
176
+ assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
177
+ });
178
+
179
+ test('should return expected',function() {
180
+ assert.equal(expected,returned)
181
+ });
182
+ })();
183
+
184
+ (function() {
185
+ console.log('when verify');
186
+ var expected = {};
187
+ var didNegotiateEnd;
188
+ verify.expect(mockContext).return(expected);
189
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
190
+ var returned = sut.verify();
191
+
192
+ function onNegotiateEnd() {
193
+ didNegotiateEnd = true;
194
+ }
195
+
196
+ test('should negotiateEnd',function() {
197
+ assert.ok(didNegotiateEnd);
198
+ });
199
+
200
+ test('should return expected',function() {
201
+ assert.equal(expected,returned)
202
+ });
203
+ })();
204
+
205
+ (function() {
206
+ console.log('when expectArray');
207
+ var expected = {};
208
+ var didNegotiateEnd;
209
+ mockContext.compositeAreCorrectArguments = null;
210
+ var array = [];
211
+ newMutableAnd.expect().return(mutableAnd);
212
+ expectArray.expect(0).expect(mockContext).expect(array).return(expected);
213
+ negotiateEnd.expect(mockContext).whenCalled(onNegotiateEnd).return();
214
+ var returned = sut.expectArray(array);
215
+
216
+ function onNegotiateEnd() {
217
+ didNegotiateEnd = true;
218
+ }
219
+
220
+ test('should negotiateEnd', function() {
221
+ assert.ok(didNegotiateEnd);
222
+ });
223
+
224
+
225
+ test('should set mockContext.compositeAreCorrectArguments to mutableAnd',function() {
226
+ assert.equal(mutableAnd,mockContext.compositeAreCorrectArguments);
227
+ });
228
+
229
+ test('should return expected',function() {
230
+ assert.equal(expected,returned)
231
+ });
232
+ })();
233
+
234
+
235
+ })();