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,67 +1,67 @@
1
- var sut = require('../expectRequire');
2
- var test = require('../test');
3
- var assert = require('assert');
4
-
5
- var fooFake = {};
6
- var bazFake = {};
7
-
8
-
9
- (function(){
10
- console.log('expectRequire');
11
-
12
- (function() {
13
- console.log('require');
14
- sut('./foo').return(fooFake);
15
- sut('./baz').return(bazFake);
16
-
17
- var firstReturned = require('./foo');
18
- var secondReturned = require('./baz');
19
- var thirdReturned = require('./foo')
20
- var fourthReturned = require('./baz');
21
-
22
- test('it should execute returns fooFake first time', function(){
23
- assert.equal(fooFake,firstReturned);
24
- });
25
-
26
- test('it should execute returns bazFake second time', function(){
27
- assert.equal(bazFake,secondReturned);
28
- });
29
-
30
- test('it should execute returns real foo third time', function(){
31
- assert.notEqual(bazFake,thirdReturned);
32
- assert.notEqual(fooFake,thirdReturned);
33
- });
34
-
35
- test('it should execute returns real foo fourth time', function(){
36
- assert.notEqual(bazFake,fourthReturned);
37
- assert.notEqual(fooFake,fourthReturned);
38
- });
39
-
40
- })();
41
-
42
- })();
43
-
44
- (function(){
45
- console.log('expectRequire reset');
46
-
47
- (function() {
48
- console.log('require');
49
- sut('./foo').return(fooFake);
50
- sut.reset();
51
- var returned = require('./foo');
52
- sut('./foo').return(fooFake);
53
- var returnedSecond = require('./foo');
54
-
55
-
56
-
57
- test('it should execute returns real foo', function(){
58
- assert.notEqual(fooFake,returned);
59
- });
60
-
61
- test('it should execute returns fake foo second time', function(){
62
- assert.equal(fooFake,returnedSecond);
63
- });
64
-
65
- })();
66
-
67
- })();
1
+ var sut = require('../expectRequire');
2
+ var test = require('../test');
3
+ var assert = require('assert');
4
+
5
+ var fooFake = {};
6
+ var bazFake = {};
7
+
8
+
9
+ (function(){
10
+ console.log('expectRequire');
11
+
12
+ (function() {
13
+ console.log('require');
14
+ sut('./foo').return(fooFake);
15
+ sut('./baz').return(bazFake);
16
+
17
+ var firstReturned = require('./foo');
18
+ var secondReturned = require('./baz');
19
+ var thirdReturned = require('./foo')
20
+ var fourthReturned = require('./baz');
21
+
22
+ test('it should execute returns fooFake first time', function(){
23
+ assert.equal(fooFake,firstReturned);
24
+ });
25
+
26
+ test('it should execute returns bazFake second time', function(){
27
+ assert.equal(bazFake,secondReturned);
28
+ });
29
+
30
+ test('it should execute returns real foo third time', function(){
31
+ assert.notEqual(bazFake,thirdReturned);
32
+ assert.notEqual(fooFake,thirdReturned);
33
+ });
34
+
35
+ test('it should execute returns real foo fourth time', function(){
36
+ assert.notEqual(bazFake,fourthReturned);
37
+ assert.notEqual(fooFake,fourthReturned);
38
+ });
39
+
40
+ })();
41
+
42
+ })();
43
+
44
+ (function(){
45
+ console.log('expectRequire reset');
46
+
47
+ (function() {
48
+ console.log('require');
49
+ sut('./foo').return(fooFake);
50
+ sut.reset();
51
+ var returned = require('./foo');
52
+ sut('./foo').return(fooFake);
53
+ var returnedSecond = require('./foo');
54
+
55
+
56
+
57
+ test('it should execute returns real foo', function(){
58
+ assert.notEqual(fooFake,returned);
59
+ });
60
+
61
+ test('it should execute returns fake foo second time', function(){
62
+ assert.equal(fooFake,returnedSecond);
63
+ });
64
+
65
+ })();
66
+
67
+ })();
package/index.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ type AnyFunction = (...args: any[]) => any;
2
+ type Tail<T extends any[]> = T extends [any, ...infer R] ? R : [];
3
+
4
+ interface RepeatControl {
5
+ repeat(times: number): RepeatControl;
6
+ repeatAny(): RepeatControl;
7
+ }
8
+
9
+ interface ExpectationTerminal<R, TArgs extends any[]> {
10
+ return(value?: R): RepeatControl;
11
+ whenCalled(callback: (...args: TArgs) => void): ExpectationTerminal<R, TArgs>;
12
+ repeat(times: number): RepeatControl;
13
+ repeatAny(): RepeatControl;
14
+ throw(error: unknown): ExpectationTerminal<R, TArgs>;
15
+ resolve(value: any): RepeatControl;
16
+ reject(value: any): RepeatControl;
17
+ }
18
+
19
+ interface ExpectationChain<TArgs extends any[], R>
20
+ extends ExpectationTerminal<R, TArgs> {
21
+ expect(arg: TArgs[0]): ExpectationChain<Tail<TArgs>, R>;
22
+ expectAnything(): ExpectationChain<Tail<TArgs>, R>;
23
+ ignore(): ExpectationChain<Tail<TArgs>, R>;
24
+ expectArray(
25
+ value: TArgs[0] extends any[] ? TArgs[0] : any[]
26
+ ): ExpectationChain<Tail<TArgs>, R>;
27
+ }
28
+
29
+ interface MockFunction<TArgs extends any[], R> {
30
+ (...args: TArgs): R;
31
+ expect(): ExpectationTerminal<R, TArgs>;
32
+ expect(...args: TArgs): ExpectationTerminal<R, TArgs>;
33
+ expect(arg: TArgs[0]): ExpectationChain<Tail<TArgs>, R>;
34
+ expectAnything(): ExpectationChain<Tail<TArgs>, R>;
35
+ ignore(): ExpectationChain<Tail<TArgs>, R>;
36
+ expectArray(
37
+ value: TArgs[0] extends any[] ? TArgs[0] : any[]
38
+ ): ExpectationChain<Tail<TArgs>, R>;
39
+ verify(): true;
40
+ reset(): void;
41
+ }
42
+
43
+ type Mocked<T> = T extends (...args: infer A) => infer R
44
+ ? MockFunction<A, R>
45
+ : T extends object
46
+ ? { [K in keyof T]: Mocked<T[K]> } & { verify: () => true }
47
+ : T;
48
+
49
+ interface RequireExpectation {
50
+ return(value: any): RequireExpectation;
51
+ repeat(times: number): RequireExpectation;
52
+ repeatAny(): RequireExpectation;
53
+ whenCalled(callback: (...args: any[]) => void): RequireExpectation;
54
+ }
55
+
56
+ interface ThenableMock<T = any> {
57
+ (valueToResolveWith?: T | null, errorToFailWith?: any): ThenableMock<T>;
58
+ then<U = T>(
59
+ success?: (value: T) => U | ThenableMock<U> | PromiseLike<U>,
60
+ fail?: (error: any) => U | ThenableMock<U> | PromiseLike<U>
61
+ ): ThenableMock<U>;
62
+ resolve(value?: T): ThenableMock<T>;
63
+ reject(error: any): ThenableMock<never>;
64
+ }
65
+
66
+ declare function mock<TArgs extends any[] = any[], R = any>(): MockFunction<
67
+ TArgs,
68
+ R
69
+ >;
70
+ declare function mock<T extends AnyFunction>(
71
+ original: T
72
+ ): MockFunction<Parameters<T>, ReturnType<T>>;
73
+ declare function mock<T extends object>(subject: T): Mocked<T>;
74
+
75
+ declare function expectRequire(moduleName: string): RequireExpectation;
76
+ declare namespace expectRequire {
77
+ function reset(): void;
78
+ }
79
+
80
+ declare function requireMock<TArgs extends any[] = any[], R = any>(
81
+ moduleName: string
82
+ ): MockFunction<TArgs, R>;
83
+ declare namespace requireMock {
84
+ function reset(): void;
85
+ }
86
+
87
+ declare function promise<T = any>(): ThenableMock<T>;
88
+
89
+ declare const aMock: {
90
+ mock: typeof mock;
91
+ expectRequire: typeof expectRequire;
92
+ requireMock: typeof requireMock;
93
+ promise: typeof promise;
94
+ };
95
+
96
+ export = aMock;
package/index.js CHANGED
@@ -1,10 +1,9 @@
1
- require('./util');
2
- require('./buffer');
3
-
4
- module.exports = {
5
- mock: require('./mock'),
6
- expectRequire: require('./expectRequire'),
7
- requireMock: require('./requireMock'),
8
- then: require('./newThen')
9
- };
10
-
1
+ require('./util');
2
+ require('./buffer');
3
+
4
+ module.exports = {
5
+ mock: require('./mock'),
6
+ expectRequire: require('./expectRequire'),
7
+ requireMock: require('./requireMock'),
8
+ promise: require('./newThen')
9
+ };
@@ -1,10 +1,10 @@
1
- function _new(context) {
2
- if (context)
3
- return context;
4
- var verify = require('../newMutableAnd')();
5
- c = {};
6
- c.verify = verify;
7
- return c;
8
- }
9
-
1
+ function _new(context) {
2
+ if (context)
3
+ return context;
4
+ var verify = require('../newMutableAnd')();
5
+ c = {};
6
+ c.verify = verify;
7
+ return c;
8
+ }
9
+
10
10
  module.exports = _new;
@@ -1,30 +1,30 @@
1
- var assert = require('assert');
2
- var test = require('../../test');
3
- var newRequireMock = require('../../partialMock/simple/newRequireMock');
4
-
5
- (function(){
6
- console.log('mockContext');
7
- var newVerify = newRequireMock('../newMutableAnd');
8
- var sut = require('../mockContext');
9
-
10
- (function() {
11
- console.log('empty input.new');
12
- var verify = {};
13
- newVerify.expect().return(verify);
14
- var returned = sut();
15
-
16
- test('it should set verify', function(){
17
- assert.equal(returned.verify,verify);
18
- });
19
- })();
20
-
21
- (function() {
22
- console.log('nonEmpty input.new');
23
- var input = {};
24
- var returned = sut(input);
25
-
26
- test('it should return same', function(){
27
- assert.equal(returned,input);
28
- });
29
- })();
30
- })();
1
+ var assert = require('assert');
2
+ var test = require('../../test');
3
+ var newRequireMock = require('../../partialMock/simple/newRequireMock');
4
+
5
+ (function(){
6
+ console.log('mockContext');
7
+ var newVerify = newRequireMock('../newMutableAnd');
8
+ var sut = require('../mockContext');
9
+
10
+ (function() {
11
+ console.log('empty input.new');
12
+ var verify = {};
13
+ newVerify.expect().return(verify);
14
+ var returned = sut();
15
+
16
+ test('it should set verify', function(){
17
+ assert.equal(returned.verify,verify);
18
+ });
19
+ })();
20
+
21
+ (function() {
22
+ console.log('nonEmpty input.new');
23
+ var input = {};
24
+ var returned = sut(input);
25
+
26
+ test('it should return same', function(){
27
+ assert.equal(returned,input);
28
+ });
29
+ })();
30
+ })();
@@ -1,16 +1,16 @@
1
- var propertyMock = require('./propertyMock');
2
-
3
- function execute(subject,mockObject) {
4
- if (!(subject instanceof Object))
5
- return;
6
- var mockFuncProperties = require('./mockFuncProperties');
7
- for(var propertyName in subject) {
8
- var property = subject[propertyName];
9
- var mockProperty = mockObject[propertyName];
10
- if (property instanceof Function)
11
- subject[propertyName] = propertyMock(subject,propertyName,mockProperty);
12
- mockFuncProperties(property,mockProperty);
13
- }
14
- }
15
-
16
- module.exports = execute;
1
+ var propertyMock = require('./propertyMock');
2
+
3
+ function execute(subject,mockObject) {
4
+ if (!(subject instanceof Object))
5
+ return;
6
+ var mockFuncProperties = require('./mockFuncProperties');
7
+ for(var propertyName in subject) {
8
+ var property = subject[propertyName];
9
+ var mockProperty = mockObject[propertyName];
10
+ if (property instanceof Function)
11
+ subject[propertyName] = propertyMock(subject,propertyName,mockProperty);
12
+ mockFuncProperties(property,mockProperty);
13
+ }
14
+ }
15
+
16
+ module.exports = execute;
@@ -1,67 +1,67 @@
1
- var assert = require('assert');
2
- var test = require('../../test');
3
- var newRequireMock = require('../../partialMock/simple/newRequireMock');
4
- var newMock = require('../../partialMock/simple/newMock');
5
-
6
- (function(){
7
- console.log('mockFuncProperties');
8
- var newPropertyMock = newRequireMock('./propertyMock');
9
- var mockFuncProperties = newRequireMock('./mockFuncProperties');
10
- var sut = require('../mockFuncProperties');
11
-
12
- (function() {
13
- console.log('subject is non-primitive');
14
- var subject = {};
15
- var a2 = {};
16
- var a = function() {};
17
- var b = {};
18
- subject.a = a;
19
- subject.b = b;
20
-
21
- var mockObject = {};
22
- var aMock = {};
23
- var b2Mock = {};
24
- var bMock = {};
25
- mockObject.a = aMock;
26
- mockObject.b = bMock;
27
-
28
- var expectedA = {};
29
- newPropertyMock.expect(subject).expect('a').expect(aMock).return(expectedA);
30
- mockFuncProperties.expect(a).expect(aMock).whenCalled(onMockSubProperties).return();
31
- mockFuncProperties.expect(b).expect(bMock).whenCalled(onMockSubProperties).return();
32
-
33
- var mockSubPropertiesCount = 0;
34
- var didMockSubProperties = false;
35
-
36
- function onMockSubProperties() {
37
- mockSubPropertiesCount++;
38
- didMockSubProperties = (mockSubPropertiesCount == 2);
39
- }
40
-
41
- sut(subject,mockObject);
42
-
43
- test('it should mock property a',function() {
44
- assert.equal(subject.a,expectedA);
45
- });
46
-
47
- test('it should mock subProperties',function() {
48
- assert.ok(didMockSubProperties);
49
- });
50
-
51
- test('it should not change property b',function() {
52
- assert.equal(subject.b,b);
53
- });
54
- })();
55
-
56
- (function() {
57
- console.log('subject is primitive');
58
- var subject = 'a';
59
- var mockObject = 'a';
60
-
61
- sut(subject,mockObject);
62
-
63
- test('it should not throw',function() {
64
- assert(true);
65
- });
66
- })();
67
- })();
1
+ var assert = require('assert');
2
+ var test = require('../../test');
3
+ var newRequireMock = require('../../partialMock/simple/newRequireMock');
4
+ var newMock = require('../../partialMock/simple/newMock');
5
+
6
+ (function(){
7
+ console.log('mockFuncProperties');
8
+ var newPropertyMock = newRequireMock('./propertyMock');
9
+ var mockFuncProperties = newRequireMock('./mockFuncProperties');
10
+ var sut = require('../mockFuncProperties');
11
+
12
+ (function() {
13
+ console.log('subject is non-primitive');
14
+ var subject = {};
15
+ var a2 = {};
16
+ var a = function() {};
17
+ var b = {};
18
+ subject.a = a;
19
+ subject.b = b;
20
+
21
+ var mockObject = {};
22
+ var aMock = {};
23
+ var b2Mock = {};
24
+ var bMock = {};
25
+ mockObject.a = aMock;
26
+ mockObject.b = bMock;
27
+
28
+ var expectedA = {};
29
+ newPropertyMock.expect(subject).expect('a').expect(aMock).return(expectedA);
30
+ mockFuncProperties.expect(a).expect(aMock).whenCalled(onMockSubProperties).return();
31
+ mockFuncProperties.expect(b).expect(bMock).whenCalled(onMockSubProperties).return();
32
+
33
+ var mockSubPropertiesCount = 0;
34
+ var didMockSubProperties = false;
35
+
36
+ function onMockSubProperties() {
37
+ mockSubPropertiesCount++;
38
+ didMockSubProperties = (mockSubPropertiesCount == 2);
39
+ }
40
+
41
+ sut(subject,mockObject);
42
+
43
+ test('it should mock property a',function() {
44
+ assert.equal(subject.a,expectedA);
45
+ });
46
+
47
+ test('it should mock subProperties',function() {
48
+ assert.ok(didMockSubProperties);
49
+ });
50
+
51
+ test('it should not change property b',function() {
52
+ assert.equal(subject.b,b);
53
+ });
54
+ })();
55
+
56
+ (function() {
57
+ console.log('subject is primitive');
58
+ var subject = 'a';
59
+ var mockObject = 'a';
60
+
61
+ sut(subject,mockObject);
62
+
63
+ test('it should not throw',function() {
64
+ assert(true);
65
+ });
66
+ })();
67
+ })();
@@ -1,23 +1,23 @@
1
- var newMockContext = require('./mockContext');
2
- var newPartialMock = require('../partialMock');
3
-
4
- function _new(subject,mockContext) {
5
- var newObjectMock = require('./objectMock');
6
-
7
- var mockContext = newMockContext(mockContext);
8
- var mock = {};
9
- mock.verify = mockContext.verify;
10
- if (subject instanceof Function) {
11
- mock = newPartialMock(subject);
12
- mockContext.verify.add(mock.verify);
13
- }
14
- if (!(subject instanceof Object))
15
- return mock;
16
- for(var propertyName in subject) {
17
- var property = subject[propertyName];
18
- mock[propertyName] = newObjectMock(property,mockContext);
19
- }
20
- return mock;
21
- }
22
-
23
- module.exports = _new
1
+ var newMockContext = require('./mockContext');
2
+ var newPartialMock = require('../partialMock');
3
+
4
+ function _new(subject,mockContext) {
5
+ var newObjectMock = require('./objectMock');
6
+
7
+ var mockContext = newMockContext(mockContext);
8
+ var mock = {};
9
+ mock.verify = mockContext.verify;
10
+ if (subject instanceof Function) {
11
+ mock = newPartialMock(subject);
12
+ mockContext.verify.add(mock.verify);
13
+ }
14
+ if (!(subject instanceof Object))
15
+ return mock;
16
+ for(var propertyName in subject) {
17
+ var property = subject[propertyName];
18
+ mock[propertyName] = newObjectMock(property,mockContext);
19
+ }
20
+ return mock;
21
+ }
22
+
23
+ module.exports = _new