Skip to content

Commit b1f9e89

Browse files
author
Brian Ojeda
committed
Add another overload and its test
1 parent 8b64266 commit b1f9e89

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export function object<T>(constructor: { new (...args: any[]): T }): DoubledObje
2020
// When passed array of props
2121
export function object<Key extends string>(props: Key[]): DoubledObjectWithKey<Key>;
2222

23+
// When passed class or constuctor function name as string value
24+
export function object<T>(object: string): DoubledObject<T>;
25+
2326
// When passed general object
2427
export function object<T>(object: T): DoubledObject<T>;
2528

test/src/typescript/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ td.when(dog.bark()).thenReturn("bark!");
1717
const bird = td.object({ fly: function(){} });
1818
td.when(bird.fly()).thenReturn("fly!");
1919

20+
class Bear { constructor() {}; sleep() {}; };
21+
const bear = td.object<Bear>("Bear");
22+
td.when(bear.sleep()).thenReturn("zzz");
23+
2024
td.replace({}, "prop");
2125
td.replace({}, "prop", 42);
2226
td.replace("../../..");

0 commit comments

Comments
 (0)