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.
- package/AUTHORS +1 -1
- package/and/newBinaryAnd.js +19 -19
- package/and/newBinaryAndSpec/test.js +67 -67
- package/and/newMonadicAnd.js +19 -19
- package/and/newMonadicAndSpec/test.js +45 -45
- package/and.js +11 -11
- package/andSpec/test.js +35 -35
- package/andSpec/testIntegration.js +24 -24
- package/eventEmitter/add.js +5 -5
- package/eventEmitter/addSpec/test.js +22 -22
- package/eventEmitter/emitterContext.js +7 -7
- package/eventEmitter/emitterContextSpec/test.js +12 -12
- package/eventEmitter/remove.js +11 -11
- package/eventEmitter/removeSpec/test.js +27 -27
- package/eventEmitter/tryAdd.js +7 -7
- package/eventEmitter/tryAddSpec/test.js +43 -43
- package/eventEmitter/tryRemove.js +7 -7
- package/eventEmitter/tryRemoveSpec/test.js +43 -43
- package/eventEmitter.js +42 -42
- package/eventEmitterSpec/test.js +142 -142
- package/expectRequire.js +20 -20
- package/expectRequireSpec/test.js +67 -67
- package/index.d.ts +96 -0
- package/index.js +9 -10
- package/mock/mockContext.js +9 -9
- package/mock/mockContextSpec/test.js +30 -30
- package/mock/mockFuncProperties.js +16 -16
- package/mock/mockFuncPropertiesSpec/test.js +67 -67
- package/mock/objectMock.js +23 -23
- package/mock/objectMockSpec/test.js +123 -123
- package/mock/propertyMock.js +13 -13
- package/mock/propertyMockSpec/test.js +36 -36
- package/mock/throwUnexpectedArguments.js +13 -13
- package/mock/throwUnexpectedArgumentsSpec/test.js +35 -35
- package/mock.js +19 -19
- package/mockSpec/test.js +65 -65
- package/mockSpec/testIntegration.js +102 -102
- package/newMutableAnd.js +18 -18
- package/newMutableAndSpec/test.js +48 -48
- package/newObject.js +4 -4
- package/newThen.js +111 -111
- package/newThenSpec/test.js +11 -11
- package/newThenSpec/testExecute.js +80 -80
- package/newThenSpec/testNoCallback.js +57 -57
- package/newThenSpec/testPreReject.js +51 -51
- package/newThenSpec/testPreRejectAndThrow.js +50 -50
- package/newThenSpec/testPreResolve.js +49 -49
- package/newThenSpec/testPreResolveAndThrow.js +48 -48
- package/newThenSpec/testReject.js +56 -56
- package/newThenSpec/testRejectAndThrow.js +56 -56
- package/newThenSpec/testResolve.js +56 -56
- package/newThenSpec/testResolveAndThrow.js +54 -54
- package/newThenSpec/testResolveWithFailingPromise.js +65 -65
- package/newThenSpec/testResolveWithPromise.js +65 -65
- package/newTrueNTimesThenFalse.js +29 -29
- package/newTrueNTimesThenFalseSpec/test.js +59 -59
- package/newTrueOnceThenFalse.js +21 -21
- package/newTrueOnceThenFalseSpec/test.js +25 -25
- package/package.json +14 -13
- package/partialMock/execute.js +18 -18
- package/partialMock/executeSpec/test.js +84 -84
- package/partialMock/expect.js +13 -13
- package/partialMock/expectAnything.js +51 -51
- package/partialMock/expectAnythingSpec/test.js +167 -167
- package/partialMock/expectArray.js +11 -11
- package/partialMock/expectArraySpec/test.js +36 -36
- package/partialMock/expectCore.js +70 -70
- package/partialMock/expectCoreSpec/test.js +241 -241
- package/partialMock/expectEmpty.js +47 -47
- package/partialMock/expectEmptySpec/test.js +194 -194
- package/partialMock/expectSpec/test.js +45 -45
- package/partialMock/fallbackWrapper/getStackTrace.js +13 -13
- package/partialMock/hasSameArgument/isEqualArg.js +68 -68
- package/partialMock/hasSameArgument/isEqualArgSpec/test.js +283 -283
- package/partialMock/ignore.js +7 -7
- package/partialMock/ignoreSpec/test.js +30 -30
- package/partialMock/mockContext/reset.js +14 -14
- package/partialMock/mockContext/resetSpec/test.js +42 -42
- package/partialMock/negotiateDecrementExpectCount.js +5 -5
- package/partialMock/negotiateDecrementExpectCountSpec/test.js +31 -31
- package/partialMock/negotiateEnd.js +10 -10
- package/partialMock/negotiateEndSpec/test.js +64 -64
- package/partialMock/negotiateIncrementExpectCount.js +5 -5
- package/partialMock/negotiateIncrementExpectCountSpec/test.js +31 -31
- package/partialMock/newExecute.js +21 -21
- package/partialMock/newExecuteSpec/test.js +61 -61
- package/partialMock/newFallbackWrapper.js +30 -30
- package/partialMock/newFallbackWrapperSpec/test.js +70 -70
- package/partialMock/newFallbackWrapperSpec/testWithMockError.js +59 -59
- package/partialMock/newFallbackWrapperSpec/testWithOtherError.js +48 -48
- package/partialMock/newHasArgument.js +9 -9
- package/partialMock/newHasArgumentSpec/test.js +36 -36
- package/partialMock/newHasEqualArgumentArray.js +23 -23
- package/partialMock/newHasEqualArgumentArraySpec/test.js +59 -59
- package/partialMock/newHasNoMoreArguments.js +15 -15
- package/partialMock/newHasNoMoreArgumentsSpec/test.js +64 -64
- package/partialMock/newHasSameArgument.js +11 -11
- package/partialMock/newHasSameArgumentSpec/test.js +80 -80
- package/partialMock/newMockContext.js +12 -12
- package/partialMock/newMockContextSpec/test.js +36 -36
- package/partialMock/newThrow.js +6 -6
- package/partialMock/newThrowSpec/test.js +20 -20
- package/partialMock/return.js +24 -24
- package/partialMock/returnSpec/test.js +106 -106
- package/partialMock/setExecute.js +15 -15
- package/partialMock/setExecuteSpec/test.js +87 -87
- package/partialMock/simple/expectRequire.js +12 -12
- package/partialMock/simple/expectRequireSpec/test.js +41 -41
- package/partialMock/simple/newMock/throwUnexpectedArguments.js +9 -9
- package/partialMock/simple/newMock/throwUnexpectedArgumentsSpec/test.js +23 -23
- package/partialMock/simple/newMock.js +10 -10
- package/partialMock/simple/newMockSpec/test.js +28 -28
- package/partialMock/simple/newPartialMock.js +124 -124
- package/partialMock/simple/newPartialMockSpec/test.js +141 -141
- package/partialMock/simple/newPartialMockSpec/testRepeat.js +63 -63
- package/partialMock/simple/newPartialMockSpec/testWithMultiArgs.js +54 -54
- package/partialMock/simple/newPartialMockSpec/testWithSingleArg.js +116 -116
- package/partialMock/simple/newRequireMock.js +12 -12
- package/partialMock/simple/newRequireMockSpec/test.js +39 -39
- package/partialMock/verify.js +7 -7
- package/partialMock/verifySpec/test.js +37 -37
- package/partialMock.js +70 -70
- package/partialMockSpec/test.js +235 -235
- package/partialMockSpec/testIntegration.js +568 -568
- package/promise.js +10 -10
- package/requireMock.js +14 -14
- package/requireMockSpec/test.js +45 -45
- package/strictMock.js +10 -10
- package/strictMockSpec/test.js +28 -28
- package/test.js +16 -16
- package/util.js +7 -1
- package/.npmignore +0 -1
|
@@ -1,42 +1,42 @@
|
|
|
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 newFallbackWrapper = newRequireMock('../newFallbackWrapper');
|
|
7
|
-
var newMutableAnd = newRequireMock('../../newMutableAnd');
|
|
8
|
-
|
|
9
|
-
var sut = require('../reset');
|
|
10
|
-
|
|
11
|
-
(function() {
|
|
12
|
-
console.log('reset mock');
|
|
13
|
-
var context = {};
|
|
14
|
-
var originalFallback = {};
|
|
15
|
-
var fallbackWrapper = {};
|
|
16
|
-
var mutableAnd = {};
|
|
17
|
-
newFallbackWrapper.expect(originalFallback).return(fallbackWrapper);
|
|
18
|
-
newMutableAnd.expect().return(mutableAnd);
|
|
19
|
-
|
|
20
|
-
sut(context,originalFallback);
|
|
21
|
-
|
|
22
|
-
test('it should set execute to fallbackWrapper',function() {
|
|
23
|
-
assert.equal(context.execute,fallbackWrapper);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('it should set originalFallback',function() {
|
|
27
|
-
assert.equal(context.originalFallback,originalFallback);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('it should set compositeAreCorrectArguments',function() {
|
|
31
|
-
assert.equal(context.compositeAreCorrectArguments,mutableAnd);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('it should set lastExecute',function() {
|
|
35
|
-
assert.equal(context.lastExecute,fallbackWrapper);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('it should set expectCount to zero',function() {
|
|
39
|
-
assert.equal(context.expectCount,0);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
})();
|
|
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 newFallbackWrapper = newRequireMock('../newFallbackWrapper');
|
|
7
|
+
var newMutableAnd = newRequireMock('../../newMutableAnd');
|
|
8
|
+
|
|
9
|
+
var sut = require('../reset');
|
|
10
|
+
|
|
11
|
+
(function() {
|
|
12
|
+
console.log('reset mock');
|
|
13
|
+
var context = {};
|
|
14
|
+
var originalFallback = {};
|
|
15
|
+
var fallbackWrapper = {};
|
|
16
|
+
var mutableAnd = {};
|
|
17
|
+
newFallbackWrapper.expect(originalFallback).return(fallbackWrapper);
|
|
18
|
+
newMutableAnd.expect().return(mutableAnd);
|
|
19
|
+
|
|
20
|
+
sut(context,originalFallback);
|
|
21
|
+
|
|
22
|
+
test('it should set execute to fallbackWrapper',function() {
|
|
23
|
+
assert.equal(context.execute,fallbackWrapper);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('it should set originalFallback',function() {
|
|
27
|
+
assert.equal(context.originalFallback,originalFallback);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('it should set compositeAreCorrectArguments',function() {
|
|
31
|
+
assert.equal(context.compositeAreCorrectArguments,mutableAnd);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('it should set lastExecute',function() {
|
|
35
|
+
assert.equal(context.lastExecute,fallbackWrapper);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('it should set expectCount to zero',function() {
|
|
39
|
+
assert.equal(context.expectCount,0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function negotiate(times,mockContext) {
|
|
2
|
-
if (times)
|
|
3
|
-
mockContext.expectCount--;
|
|
4
|
-
}
|
|
5
|
-
|
|
1
|
+
function negotiate(times,mockContext) {
|
|
2
|
+
if (times)
|
|
3
|
+
mockContext.expectCount--;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
6
|
module.exports = negotiate;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var assert = require('assert');
|
|
2
|
-
var test = require('../../test');
|
|
3
|
-
var sut = require('../negotiateDecrementExpectCount');
|
|
4
|
-
|
|
5
|
-
(function() {
|
|
6
|
-
console.log('negotiateDecrementExpectCount');
|
|
7
|
-
|
|
8
|
-
(function(){
|
|
9
|
-
console.log('times is undefined.execute');
|
|
10
|
-
var mockContext = {};
|
|
11
|
-
mockContext.expectCount = 2;
|
|
12
|
-
var times;
|
|
13
|
-
sut(times,mockContext);
|
|
14
|
-
|
|
15
|
-
test('it should not change expectCount',function() {
|
|
16
|
-
assert.ok(mockContext.expectCount,2);
|
|
17
|
-
});
|
|
18
|
-
})();
|
|
19
|
-
|
|
20
|
-
(function(){
|
|
21
|
-
console.log('times is set.execute');
|
|
22
|
-
var mockContext = {};
|
|
23
|
-
mockContext.expectCount = 2;
|
|
24
|
-
var times = 5;
|
|
25
|
-
sut(times,mockContext);
|
|
26
|
-
|
|
27
|
-
test('it should decrement expectCount',function() {
|
|
28
|
-
assert.equal(mockContext.expectCount,1);
|
|
29
|
-
});
|
|
30
|
-
})();
|
|
31
|
-
|
|
1
|
+
var assert = require('assert');
|
|
2
|
+
var test = require('../../test');
|
|
3
|
+
var sut = require('../negotiateDecrementExpectCount');
|
|
4
|
+
|
|
5
|
+
(function() {
|
|
6
|
+
console.log('negotiateDecrementExpectCount');
|
|
7
|
+
|
|
8
|
+
(function(){
|
|
9
|
+
console.log('times is undefined.execute');
|
|
10
|
+
var mockContext = {};
|
|
11
|
+
mockContext.expectCount = 2;
|
|
12
|
+
var times;
|
|
13
|
+
sut(times,mockContext);
|
|
14
|
+
|
|
15
|
+
test('it should not change expectCount',function() {
|
|
16
|
+
assert.ok(mockContext.expectCount,2);
|
|
17
|
+
});
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
(function(){
|
|
21
|
+
console.log('times is set.execute');
|
|
22
|
+
var mockContext = {};
|
|
23
|
+
mockContext.expectCount = 2;
|
|
24
|
+
var times = 5;
|
|
25
|
+
sut(times,mockContext);
|
|
26
|
+
|
|
27
|
+
test('it should decrement expectCount',function() {
|
|
28
|
+
assert.equal(mockContext.expectCount,1);
|
|
29
|
+
});
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
32
|
})();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var _return = require('./return');
|
|
2
|
-
|
|
3
|
-
function negotiateEnd(mockContext) {
|
|
4
|
-
var numberOfArgs = mockContext.numberOfArgs;
|
|
5
|
-
if (numberOfArgs === undefined)
|
|
6
|
-
return;
|
|
7
|
-
var returnValue;
|
|
8
|
-
_return(returnValue,numberOfArgs,mockContext);
|
|
9
|
-
};
|
|
10
|
-
|
|
1
|
+
var _return = require('./return');
|
|
2
|
+
|
|
3
|
+
function negotiateEnd(mockContext) {
|
|
4
|
+
var numberOfArgs = mockContext.numberOfArgs;
|
|
5
|
+
if (numberOfArgs === undefined)
|
|
6
|
+
return;
|
|
7
|
+
var returnValue;
|
|
8
|
+
_return(returnValue,numberOfArgs,mockContext);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
11
|
module.exports = negotiateEnd;
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
var test = require('../../test');
|
|
2
|
-
var assert = require('assert');
|
|
3
|
-
var requireMock = require('../simple/newRequireMock');
|
|
4
|
-
var expectRequire = require('../simple/expectRequire');
|
|
5
|
-
|
|
6
|
-
var _return = requireMock('./return');
|
|
7
|
-
var mockContext = {};
|
|
8
|
-
var sut = require('../negotiateEnd');
|
|
9
|
-
|
|
10
|
-
console.log('negotiateEnd');
|
|
11
|
-
|
|
12
|
-
(function() {
|
|
13
|
-
console.log('2 args pending.when execute');
|
|
14
|
-
var numberOfArgs = 2;
|
|
15
|
-
var didCallReturn;
|
|
16
|
-
mockContext.numberOfArgs = numberOfArgs;
|
|
17
|
-
_return.expectAnything().expect(numberOfArgs).expect(mockContext).whenCalled(onReturn).return();
|
|
18
|
-
|
|
19
|
-
function onReturn(arg) {
|
|
20
|
-
if (arg !== undefined)
|
|
21
|
-
throw new Error('expected undefined but was ' + arg);
|
|
22
|
-
didCallReturn = true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
sut(mockContext);
|
|
26
|
-
|
|
27
|
-
test('it should set void as returnValue', function() {
|
|
28
|
-
assert.ok(didCallReturn);
|
|
29
|
-
});
|
|
30
|
-
})();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(function() {
|
|
34
|
-
console.log('0 args pending.when execute');
|
|
35
|
-
var numberOfArgs = 0;
|
|
36
|
-
var didCallReturn;
|
|
37
|
-
mockContext.numberOfArgs = numberOfArgs;
|
|
38
|
-
_return.expectAnything().expect(numberOfArgs).expect(mockContext).whenCalled(onReturn).return();
|
|
39
|
-
|
|
40
|
-
function onReturn(arg) {
|
|
41
|
-
if (arg !== undefined)
|
|
42
|
-
throw new Error('expected undefined but was ' + arg);
|
|
43
|
-
didCallReturn = true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
sut(mockContext);
|
|
47
|
-
|
|
48
|
-
test('it should set void as returnValue', function() {
|
|
49
|
-
assert.ok(didCallReturn);
|
|
50
|
-
});
|
|
51
|
-
})();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(function() {
|
|
56
|
-
console.log('not pending.when execute');
|
|
57
|
-
mockContext.numberOfArgs = undefined;
|
|
58
|
-
sut(mockContext);
|
|
59
|
-
|
|
60
|
-
test('it should not set void as returnValue', function() {
|
|
61
|
-
assert.ok(1);
|
|
62
|
-
});
|
|
63
|
-
})();
|
|
64
|
-
|
|
1
|
+
var test = require('../../test');
|
|
2
|
+
var assert = require('assert');
|
|
3
|
+
var requireMock = require('../simple/newRequireMock');
|
|
4
|
+
var expectRequire = require('../simple/expectRequire');
|
|
5
|
+
|
|
6
|
+
var _return = requireMock('./return');
|
|
7
|
+
var mockContext = {};
|
|
8
|
+
var sut = require('../negotiateEnd');
|
|
9
|
+
|
|
10
|
+
console.log('negotiateEnd');
|
|
11
|
+
|
|
12
|
+
(function() {
|
|
13
|
+
console.log('2 args pending.when execute');
|
|
14
|
+
var numberOfArgs = 2;
|
|
15
|
+
var didCallReturn;
|
|
16
|
+
mockContext.numberOfArgs = numberOfArgs;
|
|
17
|
+
_return.expectAnything().expect(numberOfArgs).expect(mockContext).whenCalled(onReturn).return();
|
|
18
|
+
|
|
19
|
+
function onReturn(arg) {
|
|
20
|
+
if (arg !== undefined)
|
|
21
|
+
throw new Error('expected undefined but was ' + arg);
|
|
22
|
+
didCallReturn = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
sut(mockContext);
|
|
26
|
+
|
|
27
|
+
test('it should set void as returnValue', function() {
|
|
28
|
+
assert.ok(didCallReturn);
|
|
29
|
+
});
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
(function() {
|
|
34
|
+
console.log('0 args pending.when execute');
|
|
35
|
+
var numberOfArgs = 0;
|
|
36
|
+
var didCallReturn;
|
|
37
|
+
mockContext.numberOfArgs = numberOfArgs;
|
|
38
|
+
_return.expectAnything().expect(numberOfArgs).expect(mockContext).whenCalled(onReturn).return();
|
|
39
|
+
|
|
40
|
+
function onReturn(arg) {
|
|
41
|
+
if (arg !== undefined)
|
|
42
|
+
throw new Error('expected undefined but was ' + arg);
|
|
43
|
+
didCallReturn = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
sut(mockContext);
|
|
47
|
+
|
|
48
|
+
test('it should set void as returnValue', function() {
|
|
49
|
+
assert.ok(didCallReturn);
|
|
50
|
+
});
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
(function() {
|
|
56
|
+
console.log('not pending.when execute');
|
|
57
|
+
mockContext.numberOfArgs = undefined;
|
|
58
|
+
sut(mockContext);
|
|
59
|
+
|
|
60
|
+
test('it should not set void as returnValue', function() {
|
|
61
|
+
assert.ok(1);
|
|
62
|
+
});
|
|
63
|
+
})();
|
|
64
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function negotiate(times,mockContext) {
|
|
2
|
-
if (times)
|
|
3
|
-
mockContext.expectCount++;
|
|
4
|
-
}
|
|
5
|
-
|
|
1
|
+
function negotiate(times,mockContext) {
|
|
2
|
+
if (times)
|
|
3
|
+
mockContext.expectCount++;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
6
|
module.exports = negotiate;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var assert = require('assert');
|
|
2
|
-
var test = require('../../test');
|
|
3
|
-
var sut = require('../negotiateIncrementExpectCount');
|
|
4
|
-
|
|
5
|
-
(function() {
|
|
6
|
-
console.log('negotiateIncrementExpectCount');
|
|
7
|
-
|
|
8
|
-
(function(){
|
|
9
|
-
console.log('times is undefined.execute');
|
|
10
|
-
var mockContext = {};
|
|
11
|
-
mockContext.expectCount = 2;
|
|
12
|
-
var times;
|
|
13
|
-
sut(times,mockContext);
|
|
14
|
-
|
|
15
|
-
test('it should not change expectCount',function() {
|
|
16
|
-
assert.ok(mockContext.expectCount,2);
|
|
17
|
-
});
|
|
18
|
-
})();
|
|
19
|
-
|
|
20
|
-
(function(){
|
|
21
|
-
console.log('times is set.execute');
|
|
22
|
-
var mockContext = {};
|
|
23
|
-
mockContext.expectCount = 2;
|
|
24
|
-
var times = 5;
|
|
25
|
-
sut(times,mockContext);
|
|
26
|
-
|
|
27
|
-
test('it should increment expectCount',function() {
|
|
28
|
-
assert.equal(mockContext.expectCount,3);
|
|
29
|
-
});
|
|
30
|
-
})();
|
|
31
|
-
|
|
1
|
+
var assert = require('assert');
|
|
2
|
+
var test = require('../../test');
|
|
3
|
+
var sut = require('../negotiateIncrementExpectCount');
|
|
4
|
+
|
|
5
|
+
(function() {
|
|
6
|
+
console.log('negotiateIncrementExpectCount');
|
|
7
|
+
|
|
8
|
+
(function(){
|
|
9
|
+
console.log('times is undefined.execute');
|
|
10
|
+
var mockContext = {};
|
|
11
|
+
mockContext.expectCount = 2;
|
|
12
|
+
var times;
|
|
13
|
+
sut(times,mockContext);
|
|
14
|
+
|
|
15
|
+
test('it should not change expectCount',function() {
|
|
16
|
+
assert.ok(mockContext.expectCount,2);
|
|
17
|
+
});
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
(function(){
|
|
21
|
+
console.log('times is set.execute');
|
|
22
|
+
var mockContext = {};
|
|
23
|
+
mockContext.expectCount = 2;
|
|
24
|
+
var times = 5;
|
|
25
|
+
sut(times,mockContext);
|
|
26
|
+
|
|
27
|
+
test('it should increment expectCount',function() {
|
|
28
|
+
assert.equal(mockContext.expectCount,3);
|
|
29
|
+
});
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
32
|
})();
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
function newExecute(returnValue,hasCorrectArguments,mockContext,shouldDecrementExpectCount) {
|
|
2
|
-
var _execute = require('./execute');
|
|
3
|
-
var _fallback = mockContext.originalFallback;
|
|
4
|
-
var whenCalledEmitter = mockContext.whenCalledEmitter;
|
|
5
|
-
|
|
6
|
-
function execute() {
|
|
7
|
-
var args = [returnValue,_fallback,hasCorrectArguments,mockContext,shouldDecrementExpectCount,whenCalledEmitter];
|
|
8
|
-
for(var index = 0; index < arguments.length; index++) {
|
|
9
|
-
args.push(arguments[index]);
|
|
10
|
-
}
|
|
11
|
-
return _execute.apply(null,args);
|
|
12
|
-
returnValue,fallback,hasCorrectArguments
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
execute.setFallback = function(fallback) {
|
|
16
|
-
_fallback = fallback;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return execute;
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
function newExecute(returnValue,hasCorrectArguments,mockContext,shouldDecrementExpectCount) {
|
|
2
|
+
var _execute = require('./execute');
|
|
3
|
+
var _fallback = mockContext.originalFallback;
|
|
4
|
+
var whenCalledEmitter = mockContext.whenCalledEmitter;
|
|
5
|
+
|
|
6
|
+
function execute() {
|
|
7
|
+
var args = [returnValue,_fallback,hasCorrectArguments,mockContext,shouldDecrementExpectCount,whenCalledEmitter];
|
|
8
|
+
for(var index = 0; index < arguments.length; index++) {
|
|
9
|
+
args.push(arguments[index]);
|
|
10
|
+
}
|
|
11
|
+
return _execute.apply(null,args);
|
|
12
|
+
returnValue,fallback,hasCorrectArguments
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
execute.setFallback = function(fallback) {
|
|
16
|
+
_fallback = fallback;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return execute;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
22
|
module.exports = newExecute;
|
|
@@ -1,61 +1,61 @@
|
|
|
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 execute = newRequireMock('./execute');
|
|
7
|
-
var sut = require('../newExecute');
|
|
8
|
-
|
|
9
|
-
(function(){
|
|
10
|
-
console.log('newExecute');
|
|
11
|
-
var mockContext = {};
|
|
12
|
-
var returnValue = {};
|
|
13
|
-
var compositeAreCorrectArguments = {};
|
|
14
|
-
var originalFallback = newMock();
|
|
15
|
-
var sholdDecrementExpectCount = {};
|
|
16
|
-
var whenCalledEmitter = {};
|
|
17
|
-
|
|
18
|
-
stubMockContext()
|
|
19
|
-
|
|
20
|
-
function stubMockContext() {
|
|
21
|
-
mockContext.originalFallback = originalFallback;
|
|
22
|
-
mockContext.whenCalledEmitter = whenCalledEmitter;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var sut2 = sut(returnValue,compositeAreCorrectArguments,mockContext,sholdDecrementExpectCount);
|
|
26
|
-
|
|
27
|
-
(function() {
|
|
28
|
-
console.log('execute');
|
|
29
|
-
var arg = {};
|
|
30
|
-
var arg2 = {};
|
|
31
|
-
var expected = {};
|
|
32
|
-
mockContext.whenCalledEmitter = null;
|
|
33
|
-
execute.expect(returnValue).expect(originalFallback).expect(compositeAreCorrectArguments).expect(mockContext).expect(sholdDecrementExpectCount).expect(whenCalledEmitter).expect(arg).expect(arg2).return(expected);
|
|
34
|
-
var returned = sut2(arg,arg2)
|
|
35
|
-
|
|
36
|
-
test('it should return expected',function() {
|
|
37
|
-
assert.equal(expected,returned);
|
|
38
|
-
});
|
|
39
|
-
})();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
(function() {
|
|
43
|
-
console.log('setFallback');
|
|
44
|
-
var fallBack = {};
|
|
45
|
-
sut2.setFallback(fallBack);
|
|
46
|
-
|
|
47
|
-
(function(){
|
|
48
|
-
console.log('execute');
|
|
49
|
-
var arg = {};
|
|
50
|
-
var arg2 = {};
|
|
51
|
-
var expected = {};
|
|
52
|
-
mockContext.whenCalledEmitter = null;
|
|
53
|
-
execute.expect(returnValue).expect(fallBack).expect(compositeAreCorrectArguments).expect(mockContext).expect(sholdDecrementExpectCount).expect(whenCalledEmitter).expect(arg).expect(arg2).return(expected);
|
|
54
|
-
var returned = sut2(arg,arg2)
|
|
55
|
-
|
|
56
|
-
test('it should return expected',function() {
|
|
57
|
-
assert.equal(expected,returned);
|
|
58
|
-
});
|
|
59
|
-
})();
|
|
60
|
-
})();
|
|
61
|
-
})();
|
|
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 execute = newRequireMock('./execute');
|
|
7
|
+
var sut = require('../newExecute');
|
|
8
|
+
|
|
9
|
+
(function(){
|
|
10
|
+
console.log('newExecute');
|
|
11
|
+
var mockContext = {};
|
|
12
|
+
var returnValue = {};
|
|
13
|
+
var compositeAreCorrectArguments = {};
|
|
14
|
+
var originalFallback = newMock();
|
|
15
|
+
var sholdDecrementExpectCount = {};
|
|
16
|
+
var whenCalledEmitter = {};
|
|
17
|
+
|
|
18
|
+
stubMockContext()
|
|
19
|
+
|
|
20
|
+
function stubMockContext() {
|
|
21
|
+
mockContext.originalFallback = originalFallback;
|
|
22
|
+
mockContext.whenCalledEmitter = whenCalledEmitter;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var sut2 = sut(returnValue,compositeAreCorrectArguments,mockContext,sholdDecrementExpectCount);
|
|
26
|
+
|
|
27
|
+
(function() {
|
|
28
|
+
console.log('execute');
|
|
29
|
+
var arg = {};
|
|
30
|
+
var arg2 = {};
|
|
31
|
+
var expected = {};
|
|
32
|
+
mockContext.whenCalledEmitter = null;
|
|
33
|
+
execute.expect(returnValue).expect(originalFallback).expect(compositeAreCorrectArguments).expect(mockContext).expect(sholdDecrementExpectCount).expect(whenCalledEmitter).expect(arg).expect(arg2).return(expected);
|
|
34
|
+
var returned = sut2(arg,arg2)
|
|
35
|
+
|
|
36
|
+
test('it should return expected',function() {
|
|
37
|
+
assert.equal(expected,returned);
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
(function() {
|
|
43
|
+
console.log('setFallback');
|
|
44
|
+
var fallBack = {};
|
|
45
|
+
sut2.setFallback(fallBack);
|
|
46
|
+
|
|
47
|
+
(function(){
|
|
48
|
+
console.log('execute');
|
|
49
|
+
var arg = {};
|
|
50
|
+
var arg2 = {};
|
|
51
|
+
var expected = {};
|
|
52
|
+
mockContext.whenCalledEmitter = null;
|
|
53
|
+
execute.expect(returnValue).expect(fallBack).expect(compositeAreCorrectArguments).expect(mockContext).expect(sholdDecrementExpectCount).expect(whenCalledEmitter).expect(arg).expect(arg2).return(expected);
|
|
54
|
+
var returned = sut2(arg,arg2)
|
|
55
|
+
|
|
56
|
+
test('it should return expected',function() {
|
|
57
|
+
assert.equal(expected,returned);
|
|
58
|
+
});
|
|
59
|
+
})();
|
|
60
|
+
})();
|
|
61
|
+
})();
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var getStackTrace = require('./fallbackWrapper/getStackTrace');
|
|
2
|
-
|
|
3
|
-
function _new(originalFallback) {
|
|
4
|
-
|
|
5
|
-
var fallback = originalFallback;
|
|
6
|
-
|
|
7
|
-
function execute() {
|
|
8
|
-
Error.stackTraceLimit = Error.stackTraceLimit + 2;
|
|
9
|
-
try {
|
|
10
|
-
return fallback.apply(null,arguments);
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
if (e.name == 'Mock Error') {
|
|
14
|
-
e.stack = e.name + ': ' + e.message + '\n' + getStackTrace();
|
|
15
|
-
}
|
|
16
|
-
throw e;
|
|
17
|
-
}
|
|
18
|
-
finally {
|
|
19
|
-
Error.stackTraceLimit = Error.stackTraceLimit - 2;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
execute.setFallback = function(fallback2) {
|
|
25
|
-
fallback = fallback2;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return execute;
|
|
29
|
-
}
|
|
30
|
-
|
|
1
|
+
var getStackTrace = require('./fallbackWrapper/getStackTrace');
|
|
2
|
+
|
|
3
|
+
function _new(originalFallback) {
|
|
4
|
+
|
|
5
|
+
var fallback = originalFallback;
|
|
6
|
+
|
|
7
|
+
function execute() {
|
|
8
|
+
Error.stackTraceLimit = Error.stackTraceLimit + 2;
|
|
9
|
+
try {
|
|
10
|
+
return fallback.apply(null,arguments);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
if (e.name == 'Mock Error') {
|
|
14
|
+
e.stack = e.name + ': ' + e.message + '\n' + getStackTrace();
|
|
15
|
+
}
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
Error.stackTraceLimit = Error.stackTraceLimit - 2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
execute.setFallback = function(fallback2) {
|
|
25
|
+
fallback = fallback2;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return execute;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
31
|
module.exports = _new;
|