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
package/promise.js CHANGED
@@ -1,11 +1,11 @@
1
- var Promise = require('promise');
2
- var objectToCallback = require('./objectToCallback');
3
-
4
- function newPromise(func) {
5
- if (!func)
6
- return new Promise(objectToCallback());
7
- return new Promise(func);
8
- }
9
-
10
- newPromise.all = Promise.all;
1
+ var Promise = require('promise');
2
+ var objectToCallback = require('./objectToCallback');
3
+
4
+ function newPromise(func) {
5
+ if (!func)
6
+ return new Promise(objectToCallback());
7
+ return new Promise(func);
8
+ }
9
+
10
+ newPromise.all = Promise.all;
11
11
  module.exports = newPromise;
package/requireMock.js CHANGED
@@ -1,14 +1,14 @@
1
- var newMock = require('./mock');
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
- create.reset = expectRequire.reset;
11
-
12
- module.exports = create;
13
-
14
-
1
+ var newMock = require('./mock');
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
+ create.reset = expectRequire.reset;
11
+
12
+ module.exports = create;
13
+
14
+
@@ -1,45 +1,45 @@
1
- var assert = require('assert');
2
- var test = require('../test');
3
- var newMock = require('../partialMock/simple/newMock');
4
- var expectRequire = require('../partialMock/simple/expectRequire');
5
-
6
- var newMockMock = newMock();
7
- var expectRequireMock = newMock();
8
- expectRequireMock.clear = {};
9
-
10
- expectRequire('./mock').return(newMockMock);
11
- expectRequire('./expectRequire').return(expectRequireMock);
12
-
13
- (function() {
14
- console.log('newRequireMock');
15
- var didExpectRequireReturnMock = false;
16
- var mock = {};
17
- var moduleName = {};
18
- var expectation = {};
19
- var returnMock = newMock();
20
-
21
- newMockMock.expect().return(mock);
22
- expectRequireMock.expect(moduleName).return(expectation);
23
- expectation.return = returnMock;
24
- returnMock.expect(mock).whenCalled(onReturnMock).return(null);
25
- var sut = require('../requireMock');
26
- var returned = sut(moduleName);
27
-
28
- function onReturnMock() {
29
- didExpectRequireReturnMock = true;
30
- }
31
-
32
- test('it should return mock', function() {
33
- assert.equal(mock,returned);
34
- });
35
-
36
- test('it should expectRequire to return mock',function(){
37
- assert.ok(didExpectRequireReturnMock);
38
- });
39
-
40
- test('reset should point at expectRequire.reset',function(){
41
- assert.equal(sut.reset, expectRequireMock.reset);
42
- });
43
-
44
-
45
- })();
1
+ var assert = require('assert');
2
+ var test = require('../test');
3
+ var newMock = require('../partialMock/simple/newMock');
4
+ var expectRequire = require('../partialMock/simple/expectRequire');
5
+
6
+ var newMockMock = newMock();
7
+ var expectRequireMock = newMock();
8
+ expectRequireMock.clear = {};
9
+
10
+ expectRequire('./mock').return(newMockMock);
11
+ expectRequire('./expectRequire').return(expectRequireMock);
12
+
13
+ (function() {
14
+ console.log('newRequireMock');
15
+ var didExpectRequireReturnMock = false;
16
+ var mock = {};
17
+ var moduleName = {};
18
+ var expectation = {};
19
+ var returnMock = newMock();
20
+
21
+ newMockMock.expect().return(mock);
22
+ expectRequireMock.expect(moduleName).return(expectation);
23
+ expectation.return = returnMock;
24
+ returnMock.expect(mock).whenCalled(onReturnMock).return(null);
25
+ var sut = require('../requireMock');
26
+ var returned = sut(moduleName);
27
+
28
+ function onReturnMock() {
29
+ didExpectRequireReturnMock = true;
30
+ }
31
+
32
+ test('it should return mock', function() {
33
+ assert.equal(mock,returned);
34
+ });
35
+
36
+ test('it should expectRequire to return mock',function(){
37
+ assert.ok(didExpectRequireReturnMock);
38
+ });
39
+
40
+ test('reset should point at expectRequire.reset',function(){
41
+ assert.equal(sut.reset, expectRequireMock.reset);
42
+ });
43
+
44
+
45
+ })();
package/strictMock.js CHANGED
@@ -1,10 +1,10 @@
1
- var newPartialMock = require('./partialMock');
2
- var throwUnexpected = require('./mock/throwUnexpectedArguments');
3
-
4
- function create() {
5
- return newPartialMock(throwUnexpected);
6
- }
7
-
8
- module.exports = create;
9
-
10
-
1
+ var newPartialMock = require('./partialMock');
2
+ var throwUnexpected = require('./mock/throwUnexpectedArguments');
3
+
4
+ function create() {
5
+ return newPartialMock(throwUnexpected);
6
+ }
7
+
8
+ module.exports = create;
9
+
10
+
@@ -1,28 +1,28 @@
1
- var assert = require('assert');
2
- var test = require('../test');
3
- var expectRequire = require('../partialMock/simple/expectRequire');
4
- var newMockCore = require('../partialMock/simple/newPartialMock');
5
-
6
- function newMock() {
7
- return newMockCore(empty);
8
- }
9
-
10
- function empty() {}
11
-
12
- var throwUnexpectedArguments = {};
13
- var newPartialMock = newMock();
14
-
15
- expectRequire('./partialMock').return(newPartialMock);
16
- expectRequire('./mock/throwUnexpectedArguments').return(throwUnexpectedArguments);
17
-
18
- (function(){
19
- console.log('newMock');
20
- var partialMock = {};
21
- newPartialMock.expect(throwUnexpectedArguments).return(partialMock);
22
- var returned = require('../strictMock')();
23
-
24
- test('it should return partialMock', function(){
25
- assert.equal(partialMock,returned);
26
- });
27
-
28
- })();
1
+ var assert = require('assert');
2
+ var test = require('../test');
3
+ var expectRequire = require('../partialMock/simple/expectRequire');
4
+ var newMockCore = require('../partialMock/simple/newPartialMock');
5
+
6
+ function newMock() {
7
+ return newMockCore(empty);
8
+ }
9
+
10
+ function empty() {}
11
+
12
+ var throwUnexpectedArguments = {};
13
+ var newPartialMock = newMock();
14
+
15
+ expectRequire('./partialMock').return(newPartialMock);
16
+ expectRequire('./mock/throwUnexpectedArguments').return(throwUnexpectedArguments);
17
+
18
+ (function(){
19
+ console.log('newMock');
20
+ var partialMock = {};
21
+ newPartialMock.expect(throwUnexpectedArguments).return(partialMock);
22
+ var returned = require('../strictMock')();
23
+
24
+ test('it should return partialMock', function(){
25
+ assert.equal(partialMock,returned);
26
+ });
27
+
28
+ })();
package/test.js CHANGED
@@ -1,17 +1,17 @@
1
- var red, green, reset;
2
- red = '\u001b[31m';
3
- green = '\u001b[32m';
4
- reset = '\u001b[0m';
5
-
6
- function test(message, fn) {
7
- try {
8
- fn();
9
- console.log(green + ' OK ' + reset + message);
10
- }
11
- catch(err) {
12
- console.log(red + ' FAIL ' + reset + message);
13
- console.log(err);
14
- }
15
- }
16
-
1
+ var red, green, reset;
2
+ red = '\u001b[31m';
3
+ green = '\u001b[32m';
4
+ reset = '\u001b[0m';
5
+
6
+ function test(message, fn) {
7
+ try {
8
+ fn();
9
+ console.log(green + ' OK ' + reset + message);
10
+ }
11
+ catch(err) {
12
+ console.log(red + ' FAIL ' + reset + message);
13
+ console.log(err);
14
+ }
15
+ }
16
+
17
17
  module.exports = test;
package/util.js CHANGED
@@ -1 +1,7 @@
1
- module.exports = require('util');
1
+ function isDate(x) {
2
+ return Object.prototype.toString.call(x) === '[object Date]';
3
+ }
4
+
5
+ module.exports = {
6
+ isDate: isDate
7
+ };
package/.npmignore DELETED
@@ -1 +0,0 @@
1
- node_modules