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,54 +1,54 @@
1
- var newSut = require('../newPartialMock');
2
- var assert = require('assert');
3
- var test = require('../../../test');
4
-
5
- var originalReturnValue = {};
6
- var originalReturnValue2 = {};
7
- function original(actualArg1,actualArg2) {
8
- if (actualArg1 === arg1 && actualArg2 === arg2)
9
- return originalReturnValue2;
10
- if (actualArg1 === arg1)
11
- return originalReturnValue;
12
- }
13
-
14
- var foo ={};
15
- var baz = {};
16
- var arg1 = {};
17
- var arg2 = {};
18
-
19
-
20
- (function(){
21
- console.log('partialMockSpec multiple args.2');
22
-
23
- (function() {
24
- console.log('expect arg1,arg2 return foo once.');
25
- var sut = newSut(original);
26
- var callBackCount = 0;
27
- function onCalled(actualArg1,actualArg2) {
28
- if ((actualArg1 === arg1) && (actualArg2 === arg2))
29
- callBackCount++;
30
- }
31
-
32
- sut.expect(arg1).expect(arg2).whenCalled(onCalled).return(foo);
33
-
34
- var firstReturned = sut(arg1);
35
- var secondReturned = sut(arg1,arg2);
36
- var thirdReturned = sut(arg1,arg2);
37
-
38
- test('it should execute returns original when second arg is wrong ', function(){
39
- assert.equal(originalReturnValue,firstReturned);
40
- });
41
-
42
- test('it should execute returns foo when correct arguments', function(){
43
- assert.equal(foo,secondReturned);
44
- });
45
-
46
- test('it should execute returns original when correct argument second time', function(){
47
- assert.equal(originalReturnValue2,thirdReturned);
48
- });
49
-
50
- test('it should calls callBack once', function(){
51
- assert.equal(1,callBackCount);
52
- });
53
- })();
54
- })();
1
+ var newSut = require('../newPartialMock');
2
+ var assert = require('assert');
3
+ var test = require('../../../test');
4
+
5
+ var originalReturnValue = {};
6
+ var originalReturnValue2 = {};
7
+ function original(actualArg1,actualArg2) {
8
+ if (actualArg1 === arg1 && actualArg2 === arg2)
9
+ return originalReturnValue2;
10
+ if (actualArg1 === arg1)
11
+ return originalReturnValue;
12
+ }
13
+
14
+ var foo ={};
15
+ var baz = {};
16
+ var arg1 = {};
17
+ var arg2 = {};
18
+
19
+
20
+ (function(){
21
+ console.log('partialMockSpec multiple args.2');
22
+
23
+ (function() {
24
+ console.log('expect arg1,arg2 return foo once.');
25
+ var sut = newSut(original);
26
+ var callBackCount = 0;
27
+ function onCalled(actualArg1,actualArg2) {
28
+ if ((actualArg1 === arg1) && (actualArg2 === arg2))
29
+ callBackCount++;
30
+ }
31
+
32
+ sut.expect(arg1).expect(arg2).whenCalled(onCalled).return(foo);
33
+
34
+ var firstReturned = sut(arg1);
35
+ var secondReturned = sut(arg1,arg2);
36
+ var thirdReturned = sut(arg1,arg2);
37
+
38
+ test('it should execute returns original when second arg is wrong ', function(){
39
+ assert.equal(originalReturnValue,firstReturned);
40
+ });
41
+
42
+ test('it should execute returns foo when correct arguments', function(){
43
+ assert.equal(foo,secondReturned);
44
+ });
45
+
46
+ test('it should execute returns original when correct argument second time', function(){
47
+ assert.equal(originalReturnValue2,thirdReturned);
48
+ });
49
+
50
+ test('it should calls callBack once', function(){
51
+ assert.equal(1,callBackCount);
52
+ });
53
+ })();
54
+ })();
@@ -1,116 +1,116 @@
1
- var newSut = require('../newPartialMock');
2
- var assert = require('assert');
3
- var test = require('../../../test');
4
-
5
- var originalReturnValue = {};
6
- function original() {
7
- return originalReturnValue;
8
- }
9
-
10
- var foo ={};
11
- var baz = {};
12
- var arg1 = {};
13
-
14
-
15
- (function(){
16
- console.log('partialMockSpec');
17
-
18
- (function() {
19
- console.log('expect return foo once.');
20
- var sut = newSut(original);
21
- require('../newPartialMock')(function() {});
22
- sut.expect(arg1).return(foo);
23
- var s = require('../newPartialMock')(function() {});
24
- var firstReturned = sut({});
25
- var secondReturned = sut(arg1);
26
- var thirdReturned = sut(arg1);
27
-
28
- test('it should execute returns original when wrong argument', function(){
29
- assert.equal(originalReturnValue,firstReturned);
30
- });
31
-
32
- test('it should execute returns foo when correct argument', function(){
33
- assert.equal(foo,secondReturned);
34
- });
35
-
36
- test('it should execute returns original when correct argument second time', function(){
37
- assert.equal(originalReturnValue,thirdReturned);
38
- });
39
-
40
- })();
41
-
42
- (function() {
43
- console.log('expect return foo twice.');
44
-
45
- var sut = newSut(original);
46
- sut.expect(arg1).return(foo);
47
- sut.expect(arg1).return(foo);
48
-
49
- var firstReturned = sut(arg1);
50
- var secondReturned = sut(arg1);
51
- var thirdReturned = sut(arg1);
52
-
53
- test('it should execute returns foo first time', function(){
54
- assert.equal(foo,firstReturned);
55
- });
56
-
57
- test('it should execute returns foo second time', function(){
58
- assert.equal(foo,secondReturned);
59
- });
60
-
61
- test('it should execute returns original third time', function(){
62
- assert.equal(originalReturnValue,thirdReturned);
63
- });
64
-
65
- })();
66
-
67
-
68
- (function() {
69
- console.log('expect return foo then baz');
70
- var sut = newSut(original);
71
- sut.expect().return(foo);
72
- sut.expect(arg1).return(baz);
73
-
74
- var firstReturned = sut();
75
- var secondReturned = sut(arg1);
76
- var thirdReturned = sut(arg1);
77
-
78
- test('it should execute returns foo first time', function(){
79
- assert.equal(foo,firstReturned);
80
- });
81
-
82
- test('it should execute returns baz second time', function(){
83
- assert.equal(baz,secondReturned);
84
- });
85
-
86
- test('it should execute returns original third time', function(){
87
- assert.equal(originalReturnValue,thirdReturned);
88
- });
89
-
90
- })();
91
-
92
- (function() {
93
- console.log('expect anything return foo, then expect arg1 return baz.');
94
- var sut = newSut(original);
95
- sut.expectAnything().return(foo);
96
- sut.expect(arg1).return(baz);
97
-
98
- var firstReturned = sut('abc');
99
- var secondReturned = sut('abc');
100
- var thirdReturned = sut(arg1);
101
-
102
- test('it should execute returns foo first time', function(){
103
- assert.equal(foo,firstReturned);
104
- });
105
-
106
- test('it should execute returns original second time', function(){
107
- assert.equal(originalReturnValue,secondReturned);
108
- });
109
-
110
- test('it should execute returns baz third time', function(){
111
- assert.equal(baz,thirdReturned);
112
- });
113
-
114
- })();
115
-
116
- })();
1
+ var newSut = require('../newPartialMock');
2
+ var assert = require('assert');
3
+ var test = require('../../../test');
4
+
5
+ var originalReturnValue = {};
6
+ function original() {
7
+ return originalReturnValue;
8
+ }
9
+
10
+ var foo ={};
11
+ var baz = {};
12
+ var arg1 = {};
13
+
14
+
15
+ (function(){
16
+ console.log('partialMockSpec');
17
+
18
+ (function() {
19
+ console.log('expect return foo once.');
20
+ var sut = newSut(original);
21
+ require('../newPartialMock')(function() {});
22
+ sut.expect(arg1).return(foo);
23
+ var s = require('../newPartialMock')(function() {});
24
+ var firstReturned = sut({});
25
+ var secondReturned = sut(arg1);
26
+ var thirdReturned = sut(arg1);
27
+
28
+ test('it should execute returns original when wrong argument', function(){
29
+ assert.equal(originalReturnValue,firstReturned);
30
+ });
31
+
32
+ test('it should execute returns foo when correct argument', function(){
33
+ assert.equal(foo,secondReturned);
34
+ });
35
+
36
+ test('it should execute returns original when correct argument second time', function(){
37
+ assert.equal(originalReturnValue,thirdReturned);
38
+ });
39
+
40
+ })();
41
+
42
+ (function() {
43
+ console.log('expect return foo twice.');
44
+
45
+ var sut = newSut(original);
46
+ sut.expect(arg1).return(foo);
47
+ sut.expect(arg1).return(foo);
48
+
49
+ var firstReturned = sut(arg1);
50
+ var secondReturned = sut(arg1);
51
+ var thirdReturned = sut(arg1);
52
+
53
+ test('it should execute returns foo first time', function(){
54
+ assert.equal(foo,firstReturned);
55
+ });
56
+
57
+ test('it should execute returns foo second time', function(){
58
+ assert.equal(foo,secondReturned);
59
+ });
60
+
61
+ test('it should execute returns original third time', function(){
62
+ assert.equal(originalReturnValue,thirdReturned);
63
+ });
64
+
65
+ })();
66
+
67
+
68
+ (function() {
69
+ console.log('expect return foo then baz');
70
+ var sut = newSut(original);
71
+ sut.expect().return(foo);
72
+ sut.expect(arg1).return(baz);
73
+
74
+ var firstReturned = sut();
75
+ var secondReturned = sut(arg1);
76
+ var thirdReturned = sut(arg1);
77
+
78
+ test('it should execute returns foo first time', function(){
79
+ assert.equal(foo,firstReturned);
80
+ });
81
+
82
+ test('it should execute returns baz second time', function(){
83
+ assert.equal(baz,secondReturned);
84
+ });
85
+
86
+ test('it should execute returns original third time', function(){
87
+ assert.equal(originalReturnValue,thirdReturned);
88
+ });
89
+
90
+ })();
91
+
92
+ (function() {
93
+ console.log('expect anything return foo, then expect arg1 return baz.');
94
+ var sut = newSut(original);
95
+ sut.expectAnything().return(foo);
96
+ sut.expect(arg1).return(baz);
97
+
98
+ var firstReturned = sut('abc');
99
+ var secondReturned = sut('abc');
100
+ var thirdReturned = sut(arg1);
101
+
102
+ test('it should execute returns foo first time', function(){
103
+ assert.equal(foo,firstReturned);
104
+ });
105
+
106
+ test('it should execute returns original second time', function(){
107
+ assert.equal(originalReturnValue,secondReturned);
108
+ });
109
+
110
+ test('it should execute returns baz third time', function(){
111
+ assert.equal(baz,thirdReturned);
112
+ });
113
+
114
+ })();
115
+
116
+ })();
@@ -1,12 +1,12 @@
1
- var newMock = require('./newMock');
2
- var expectRequire = require('./expectRequire');
3
-
4
- function create(moduleName) {
5
- var mock = newMock();
6
- expectRequire(moduleName).return(mock);
7
- return mock;
8
- }
9
-
10
- module.exports = create;
11
-
12
-
1
+ var newMock = require('./newMock');
2
+ var expectRequire = require('./expectRequire');
3
+
4
+ function create(moduleName) {
5
+ var mock = newMock();
6
+ expectRequire(moduleName).return(mock);
7
+ return mock;
8
+ }
9
+
10
+ module.exports = create;
11
+
12
+
@@ -1,39 +1,39 @@
1
- var assert = require('assert');
2
- var test = require('../../../test');
3
- var newMock = require('../newMock');
4
- var expectRequire = require('../expectRequire');
5
-
6
- var newMockMock = newMock();
7
- var expectRequireMock = newMock();
8
-
9
- expectRequire('./newMock').return(newMockMock);
10
- expectRequire('./expectRequire').return(expectRequireMock);
11
-
12
- (function() {
13
- console.log('newRequireMock');
14
- var didExpectRequireReturnMock = false;
15
- var mock = {};
16
- var moduleName = {};
17
- var expectation = {};
18
- var returnMock = newMock();
19
-
20
- newMockMock.expect().return(mock);
21
- expectRequireMock.expect(moduleName).return(expectation);
22
- expectation.return = returnMock;
23
- returnMock.expect(mock).whenCalled(onReturnMock).return(null);
24
-
25
- var returned = require('../newRequireMock')(moduleName);
26
-
27
- function onReturnMock() {
28
- didExpectRequireReturnMock = true;
29
- }
30
-
31
- test('it should return mock', function() {
32
- assert.equal(mock,returned);
33
- });
34
-
35
- test('it should expectRequire to return mock',function(){
36
- assert.ok(didExpectRequireReturnMock);
37
- });
38
-
39
- })();
1
+ var assert = require('assert');
2
+ var test = require('../../../test');
3
+ var newMock = require('../newMock');
4
+ var expectRequire = require('../expectRequire');
5
+
6
+ var newMockMock = newMock();
7
+ var expectRequireMock = newMock();
8
+
9
+ expectRequire('./newMock').return(newMockMock);
10
+ expectRequire('./expectRequire').return(expectRequireMock);
11
+
12
+ (function() {
13
+ console.log('newRequireMock');
14
+ var didExpectRequireReturnMock = false;
15
+ var mock = {};
16
+ var moduleName = {};
17
+ var expectation = {};
18
+ var returnMock = newMock();
19
+
20
+ newMockMock.expect().return(mock);
21
+ expectRequireMock.expect(moduleName).return(expectation);
22
+ expectation.return = returnMock;
23
+ returnMock.expect(mock).whenCalled(onReturnMock).return(null);
24
+
25
+ var returned = require('../newRequireMock')(moduleName);
26
+
27
+ function onReturnMock() {
28
+ didExpectRequireReturnMock = true;
29
+ }
30
+
31
+ test('it should return mock', function() {
32
+ assert.equal(mock,returned);
33
+ });
34
+
35
+ test('it should expectRequire to return mock',function(){
36
+ assert.ok(didExpectRequireReturnMock);
37
+ });
38
+
39
+ })();
@@ -1,8 +1,8 @@
1
- function verify(mockContext) {
2
- var count = mockContext.expectCount;
3
- if (count > 0)
4
- throw new Error('mock has ' + count + ' pending functions');
5
- return true;
6
- }
7
-
1
+ function verify(mockContext) {
2
+ var count = mockContext.expectCount;
3
+ if (count > 0)
4
+ throw new Error('mock has ' + count + ' pending functions');
5
+ return true;
6
+ }
7
+
8
8
  module.exports = verify;
@@ -1,38 +1,38 @@
1
- var assert = require('assert');
2
- var test = require('../../test');
3
-
4
- var sut = require('../verify');
5
-
6
- (function() {
7
- console.log('verifySpec');
8
-
9
- (function(){
10
- console.log('expectCount is zero.execute');
11
- var mockContext = {};
12
- mockContext.expectCount = 0;
13
- var returned = sut(mockContext);
14
-
15
- test('it should return true',function() {
16
- assert.ok(returned);
17
- });
18
- })();
19
-
20
- (function(){
21
- console.log('expectCount is above zero.execute');
22
- var mockContext = {};
23
- mockContext.expectCount = 2;
24
- var msg;
25
- try {
26
- var returned = sut(mockContext);
27
- }
28
- catch(err) {
29
- msg = err.message;
30
- }
31
-
32
-
33
- test('it should throw mock has 2 pending functions',function() {
34
- assert.equal(msg,'mock has 2 pending functions');
35
- });
36
- })();
37
-
1
+ var assert = require('assert');
2
+ var test = require('../../test');
3
+
4
+ var sut = require('../verify');
5
+
6
+ (function() {
7
+ console.log('verifySpec');
8
+
9
+ (function(){
10
+ console.log('expectCount is zero.execute');
11
+ var mockContext = {};
12
+ mockContext.expectCount = 0;
13
+ var returned = sut(mockContext);
14
+
15
+ test('it should return true',function() {
16
+ assert.ok(returned);
17
+ });
18
+ })();
19
+
20
+ (function(){
21
+ console.log('expectCount is above zero.execute');
22
+ var mockContext = {};
23
+ mockContext.expectCount = 2;
24
+ var msg;
25
+ try {
26
+ var returned = sut(mockContext);
27
+ }
28
+ catch(err) {
29
+ msg = err.message;
30
+ }
31
+
32
+
33
+ test('it should throw mock has 2 pending functions',function() {
34
+ assert.equal(msg,'mock has 2 pending functions');
35
+ });
36
+ })();
37
+
38
38
  })();
package/partialMock.js CHANGED
@@ -1,70 +1,70 @@
1
- function create(originalFunc) {
2
- var newMockContext = require('./partialMock/newMockContext');
3
- var expect = require('./partialMock/expect');
4
- var expectAnything = require('./partialMock/expectAnything');
5
- var ignore = require('./partialMock/ignore');
6
- var expectArray = require('./partialMock/expectArray');
7
- var verify = require('./partialMock/verify');
8
- var expectEmpty = require('./partialMock/expectEmpty');
9
- var newEmptyAnd = require('./newMutableAnd');
10
- var mockContext = newMockContext(originalFunc);
11
- var _negotiateEnd = require('./partialMock/negotiateEnd');
12
-
13
- function mock() {
14
- negotiateEnd();
15
- mockContext.arguments = arguments;
16
- return mockContext.execute.apply(null,arguments);
17
- }
18
-
19
- mock.expect = function() {
20
- negotiateEnd();
21
- mockContext.compositeAreCorrectArguments = newEmptyAnd();
22
- if (arguments.length == 0)
23
- return expectEmpty(mockContext);
24
- var args = [0,mockContext];
25
- for (var i = 0 ; i < arguments.length; i++) {
26
- args.push(arguments[i]);
27
- };
28
- return expect.apply(null,args);
29
- };
30
-
31
- mock.expectAnything = function() {
32
- negotiateEnd();
33
- mockContext.compositeAreCorrectArguments = newEmptyAnd();
34
- var args = [0,mockContext];
35
- return expectAnything.apply(null,args);
36
- };
37
-
38
- mock.ignore = function() {
39
- negotiateEnd();
40
- mockContext.compositeAreCorrectArguments = newEmptyAnd();
41
- var args = [0,mockContext];
42
- return ignore.apply(null,args);
43
- };
44
-
45
- mock.reset = mockContext.reset;
46
-
47
- mock.verify = function() {
48
- negotiateEnd();
49
- var args = [mockContext];
50
- return verify.apply(null,args);
51
- };
52
-
53
- mock.expectArray = function(array) {
54
- negotiateEnd();
55
- mockContext.compositeAreCorrectArguments = newEmptyAnd();
56
- var args = [0,mockContext,array];
57
- return expectArray.apply(null,args);
58
- }
59
-
60
-
61
- function negotiateEnd() {
62
- _negotiateEnd(mockContext);
63
- }
64
-
65
- return mock;
66
- }
67
-
68
- module.exports = create;
69
-
70
-
1
+ function create(originalFunc) {
2
+ var newMockContext = require('./partialMock/newMockContext');
3
+ var expect = require('./partialMock/expect');
4
+ var expectAnything = require('./partialMock/expectAnything');
5
+ var ignore = require('./partialMock/ignore');
6
+ var expectArray = require('./partialMock/expectArray');
7
+ var verify = require('./partialMock/verify');
8
+ var expectEmpty = require('./partialMock/expectEmpty');
9
+ var newEmptyAnd = require('./newMutableAnd');
10
+ var mockContext = newMockContext(originalFunc);
11
+ var _negotiateEnd = require('./partialMock/negotiateEnd');
12
+
13
+ function mock() {
14
+ negotiateEnd();
15
+ mockContext.arguments = arguments;
16
+ return mockContext.execute.apply(null,arguments);
17
+ }
18
+
19
+ mock.expect = function() {
20
+ negotiateEnd();
21
+ mockContext.compositeAreCorrectArguments = newEmptyAnd();
22
+ if (arguments.length == 0)
23
+ return expectEmpty(mockContext);
24
+ var args = [0,mockContext];
25
+ for (var i = 0 ; i < arguments.length; i++) {
26
+ args.push(arguments[i]);
27
+ };
28
+ return expect.apply(null,args);
29
+ };
30
+
31
+ mock.expectAnything = function() {
32
+ negotiateEnd();
33
+ mockContext.compositeAreCorrectArguments = newEmptyAnd();
34
+ var args = [0,mockContext];
35
+ return expectAnything.apply(null,args);
36
+ };
37
+
38
+ mock.ignore = function() {
39
+ negotiateEnd();
40
+ mockContext.compositeAreCorrectArguments = newEmptyAnd();
41
+ var args = [0,mockContext];
42
+ return ignore.apply(null,args);
43
+ };
44
+
45
+ mock.reset = mockContext.reset;
46
+
47
+ mock.verify = function() {
48
+ negotiateEnd();
49
+ var args = [mockContext];
50
+ return verify.apply(null,args);
51
+ };
52
+
53
+ mock.expectArray = function(array) {
54
+ negotiateEnd();
55
+ mockContext.compositeAreCorrectArguments = newEmptyAnd();
56
+ var args = [0,mockContext,array];
57
+ return expectArray.apply(null,args);
58
+ }
59
+
60
+
61
+ function negotiateEnd() {
62
+ _negotiateEnd(mockContext);
63
+ }
64
+
65
+ return mock;
66
+ }
67
+
68
+ module.exports = create;
69
+
70
+