Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/spy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,10 @@ type DeepPartialMock<T extends Procedure | Constructable = Procedure> = Mock<
export type MaybeMockedConstructor<T> = T extends Constructable
? Mock<T>
: T
export type MockedFunction<T extends Procedure | Constructable> = Mock<T> & {
[K in keyof T]: T[K];
}
export type PartiallyMockedFunction<T extends Procedure | Constructable> = PartialMock<T> & {
[K in keyof T]: T[K];
}
export type MockedFunction<T extends Procedure | Constructable> = Mock<T>
& MockedObject<T>
export type PartiallyMockedFunction<T extends Procedure | Constructable> = PartialMock<T>
& MockedObject<T>
export type MockedFunctionDeep<T extends Procedure | Constructable> = Mock<T>
& MockedObjectDeep<T>
export type PartiallyMockedFunctionDeep<T extends Procedure | Constructable> = DeepPartialMock<T>
Expand Down
6 changes: 6 additions & 0 deletions test/core/test/vi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ describe('testing vi utils', () => {
public getBar(): string {
return this.bar
}

static getBaz(): string {
return 'baz'
}
}
class FooMock implements Mocked<Foo> {
readonly barMock: Mock<() => string> = vi.fn()
Expand All @@ -168,6 +172,8 @@ describe('testing vi utils', () => {
if (0) {
vi.mocked(Foo).mockImplementation(FooMock)
vi.mocked(Foo).mockImplementation(Foo)
vi.mocked(Foo).getBaz.mockImplementation(() => 'baz')
vi.mocked(Foo, { partial: true }).getBaz.mockImplementation(() => 'baz')
}
})

Expand Down
Loading