diff --git a/index.d.ts b/index.d.ts index b55fd58c..2ceee07c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,11 +2,11 @@ // types and interfaces // ---------------------------------------------------------------------------- -export type DoubledObject = Subject; +export type DoubledObject = T; -export type DoubledObjectWithKey = {}; +export type DoubledObjectWithKey = { [K in T] }; -export type TestDouble = Function; +export type TestDouble = T; export type TestDoubleConstructor = Constructor; @@ -156,7 +156,7 @@ export function object(constructor: Constructor ): DoubledObject; * @param {Key[]} props Array of properties. * @returns {DoubledObjectWithKey} */ -export function object(props: Key[]): DoubledObjectWithKey; +export function object(props: T[]): DoubledObjectWithKey; /** * Create a fake empty object that is cast as the generic using a Proxy object. diff --git a/test/src/typescript/test.ts b/test/src/typescript/test.ts index 248bef2b..5a3a6d42 100644 --- a/test/src/typescript/test.ts +++ b/test/src/typescript/test.ts @@ -43,6 +43,10 @@ td.when(dog.bark()).thenReturn("bark!"); // td.object() +const cat = td.object(["scratch","meow"]); +td.when(cat.scratch()).thenReturn("scratch!"); +td.when(cat.meow()).thenReturn("meow!"); + const bird = td.object({ fly: function(){} }); td.when(bird.fly()).thenReturn("fly!");