File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " unstoppable-mockery" ,
3- "version" : " 1.0.1 " ,
3+ "version" : " 1.1.0 " ,
44 "main" : " dist/index.js" ,
55 "types" : " dist/index.d.ts" ,
66 "license" : " Apache-2.0" ,
6262 "ts-jest" : " ^29.4.1" ,
6363 "typescript" : " ^5.9.2" ,
6464 "typescript-eslint" : " ^8.39.0"
65+ },
66+ "dependencies" : {
67+ "type-fest" : " ^5.0.1"
6568 }
6669}
Original file line number Diff line number Diff line change 1- import type { Mocked } from './types ' ;
1+ import type { PartialDeep } from 'type-fest ' ;
22
3+ import type { Mocked } from './types' ;
34/**
45 * Creates a mocked version of a class, replacing all prototype methods with jest mock functions.
56 *
@@ -26,7 +27,7 @@ import type { Mocked } from './types';
2627 */
2728export function mockClass < T > (
2829 template : new ( ...args : any [ ] ) => T ,
29- properties : Partial < T > = { } ,
30+ properties ?: PartialDeep < T > ,
3031) : Mocked < T > {
3132 const mockedObject = Object . getOwnPropertyNames ( template . prototype ) . reduce (
3233 ( prev , current ) => {
Original file line number Diff line number Diff line change 1+ import type { PartialDeep } from 'type-fest' ;
2+
13import type { Mocked } from './types' ;
24
35/**
@@ -24,12 +26,12 @@ import type { Mocked } from './types';
2426 * @returns A mocked object based on an interface or class type
2527 */
2628export function mockInterface < T extends object > (
27- overrides ?: Partial < T > ,
29+ overrides ?: PartialDeep < T > ,
2830) : Mocked < T > {
2931 return new Proxy ( { } as Mocked < T > , {
3032 get : ( target , name ) => {
3133 if ( overrides && name in overrides ) {
32- return overrides [ name as keyof T ] ;
34+ return overrides [ name as keyof PartialDeep < T > ] ;
3335 }
3436
3537 if (
@@ -43,4 +45,3 @@ export function mockInterface<T extends object>(
4345 } ,
4446 } ) ;
4547}
46- //
Original file line number Diff line number Diff line change @@ -2822,6 +2822,11 @@ synckit@^0.11.7, synckit@^0.11.8:
28222822 dependencies :
28232823 " @pkgr/core" " ^0.2.9"
28242824
2825+ tagged-tag@^1.0.0 :
2826+ version "1.0.0"
2827+ resolved "https://packages.atlassian.com/api/npm/npm-remote/tagged-tag/-/tagged-tag-1.0.0.tgz#a0b5917c2864cba54841495abfa3f6b13edcf4d6"
2828+ integrity sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==
2829+
28252830test-exclude@^6.0.0 :
28262831 version "6.0.0"
28272832 resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"
@@ -2890,6 +2895,13 @@ type-fest@^4.41.0:
28902895 resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.41.0.tgz#6ae1c8e5731273c2bf1f58ad39cbae2c91a46c58"
28912896 integrity sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==
28922897
2898+ type-fest@^5.0.1 :
2899+ version "5.0.1"
2900+ resolved "https://packages.atlassian.com/api/npm/npm-remote/type-fest/-/type-fest-5.0.1.tgz#546c87966765f88f4f36e0521be4b3d0215b4cab"
2901+ integrity sha512-9MpwAI52m8H6ssA542UxSLnSiSD2dsC3/L85g6hVubLSXd82wdI80eZwTWhdOfN67NlA+D+oipAs1MlcTcu3KA==
2902+ dependencies :
2903+ tagged-tag "^1.0.0"
2904+
28932905typescript-eslint@^8.39.0 :
28942906 version "8.39.1"
28952907 resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.39.1.tgz#13075a676522041cbe421d98fb504ef535a6e4b3"
You can’t perform that action at this time.
0 commit comments