Skip to content

Commit 0c07eb0

Browse files
author
Mathias Lorenzen
committed
fix #8.
1 parent 80b8032 commit 0c07eb0

File tree

7 files changed

+141
-23
lines changed

7 files changed

+141
-23
lines changed

dist/spec/issues/8.test.js

+73-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spec/issues/8.test.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Substitute.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { ObjectSubstitute, OmitProxyMethods, DisabledSubstituteObject } from "./
22
export declare const HandlerKey: unique symbol;
33
export declare const AreProxiesDisabledKey: unique symbol;
44
export declare class Substitute {
5-
static for<T>(): ObjectSubstitute<OmitProxyMethods<T>, T>;
5+
static for<T>(): ObjectSubstitute<OmitProxyMethods<T>, T> & T;
66
static disableFor<T extends ObjectSubstitute<OmitProxyMethods<any>>>(substitute: T): DisabledSubstituteObject<T>;
77
}

dist/src/Substitute.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+24-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/issues/8.test.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Substitute from "../../src/Index";
2+
import test from 'ava';
3+
4+
class ClassA {
5+
constructor(){}
6+
7+
methodA(): string {
8+
return 'abc'
9+
}
10+
}
11+
12+
class ClassB {
13+
constructor(
14+
private classA: ClassA
15+
) {}
16+
17+
methodB(): string {
18+
return this.classA.methodA();
19+
}
20+
21+
methodB2(): string {
22+
return 'def'
23+
}
24+
}
25+
26+
class ClassC {
27+
constructor(
28+
private classB: ClassB
29+
) {}
30+
31+
methodC(): string {
32+
return this.classB.methodB2();
33+
}
34+
}
35+
36+
test('issue 9: can record method with 0 arguments', async t => {
37+
const classBMock = Substitute.for<ClassB>();
38+
const classC = new ClassC(classBMock);
39+
t.not(classC, null);
40+
});

src/Substitute.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const HandlerKey = Symbol();
55
export const AreProxiesDisabledKey = Symbol();
66

77
export class Substitute {
8-
static for<T>(): ObjectSubstitute<OmitProxyMethods<T>, T> {
8+
static for<T>(): ObjectSubstitute<OmitProxyMethods<T>, T> & T {
99
const objectContext = new Context();
1010
return objectContext.rootProxy;
1111
}

0 commit comments

Comments
 (0)