Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mock property support symbol #62

Merged
merged 1 commit into from
Dec 21, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"node": ">= 18.19.0"
},
"dependencies": {
"@cnpmjs/muk-prop": "^1.0.0",
"@cnpmjs/muk-prop": "^1.1.0",
"is-type-of": "^2.2.0",
"thenify": "^3.3.1"
},
Expand Down
87 changes: 0 additions & 87 deletions src/index.d.ts

This file was deleted.

34 changes: 17 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
// @ts-ignore
import thenify from 'thenify';

function mock(target: any, property: string, value?: any) {
function mock(target: any, property: PropertyKey, value?: any) {
value = spyFunction(target, property, value);
return muk(target, property, value);
}

function spyFunction(target: any, property: string, fn: any) {
function spyFunction(target: any, property: PropertyKey, fn: any) {
if (!is.function(fn)) return fn;
// support mock with jest.fn()
if (fn._isMockFunction && fn.mock) return fn;
Expand All @@ -32,14 +32,14 @@
fn.called++;
const res = Reflect.apply(target, thisArg, args);
if (isAsyncLike && !is.promise(res)) {
throw new Error(`Can\'t mock async function to normal function for property "${property}"`);
throw new Error(`Can\'t mock async function to normal function for property "${String(property)}"`);
}
return res;
},
});
}

function isAsyncLikeFunction(target: any, property: string) {
function isAsyncLikeFunction(target: any, property: PropertyKey) {
// don't call getter
// Object.getOwnPropertyDescriptor can't find getter in prototypes
if (typeof target.__lookupGetter__ === 'function' && target.__lookupGetter__(property)) return false;
Expand Down Expand Up @@ -90,7 +90,7 @@
return error;
}

function _mockError(mod: any, method: string, error?: MockError, props?: Record<string, any> | number,
function _mockError(mod: any, method: string | symbol, error?: MockError, props?: Record<string, any> | number,
timeout?: number | string, once?: boolean) {
if (typeof props === 'number') {
timeout = props;
Expand Down Expand Up @@ -134,13 +134,13 @@

/**
* Mock async function error.
* @param {Object} mod, module object

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 137 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"
* @param {String} method, mock module object method name.
* @param {String|Error} error, error string message or error instance.
* @param {Object} props, error properties
* @param {Number} timeout, mock async callback timeout, default is 0.
*/
function mockError(mod: any, method: string, error?: MockError,
function mockError(mod: any, method: string | symbol, error?: MockError,
props?: Record<string, any> | number,
timeout?: number) {
return _mockError(mod, method, error, props, timeout);
Expand All @@ -148,13 +148,13 @@

/**
* Mock async function error once.
* @param {Object} mod, module object

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"

Check warning on line 151 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props, timeout". Got "mod,, method,, error,, props,, timeout,"
* @param {String} method, mock module object method name.
* @param {String|Error} error, error string message or error instance.
* @param {Object} props, error properties
* @param {Number} timeout, mock async callback timeout, default is 0.
*/
function errorOnce(mod: any, method: string, error?: MockError,
function errorOnce(mod: any, method: string | symbol, error?: MockError,
props?: Record<string, any> | number,
timeout?: number) {
return _mockError(mod, method, error, props, timeout, true);
Expand All @@ -163,12 +163,12 @@
/**
* mock return callback(null, data1, data2).
*
* @param {Object} mod, module object

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"

Check warning on line 166 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, datas, timeout". Got "mod,, method,, datas,, timeout,"
* @param {String} method, mock module object method name.
* @param {Array} datas, return datas array.
* @param {Number} timeout, mock async callback timeout, default is 10.
*/
function mockDatas(mod: any, method: string, datas: any[] | any, timeout?: number) {
function mockDatas(mod: any, method: string | symbol, datas: any[] | any, timeout?: number) {
if (timeout) {
timeout = parseInt(String(timeout), 10);
}
Expand Down Expand Up @@ -203,12 +203,12 @@
/**
* mock return callback(null, data).
*
* @param {Object} mod, module object

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"

Check warning on line 206 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, data, timeout". Got "mod,, method,, data,, timeout,"
* @param {String} method, mock module object method name.
* @param {Object} data, return data.
* @param {Number} timeout, mock async callback timeout, default is 0.
*/
function mockData(mod: any, method: string, data: any, timeout?: number) {
function mockData(mod: any, method: string | symbol, data: any, timeout?: number) {
const isGeneratorFunction = is.generatorFunction(mod[method]);
const isAsyncFunction = is.asyncFunction(mod[method]);
if (isGeneratorFunction || isAsyncFunction) {
Expand All @@ -217,7 +217,7 @@
return mockDatas(mod, method, [ data ], timeout);
}

function dataWithAsyncDispose(mod: any, method: string, data: any, timeout?: number) {
function dataWithAsyncDispose(mod: any, method: string | symbol, data: any, timeout?: number) {
data = {
...data,
async [Symbol.asyncDispose]() {
Expand All @@ -230,22 +230,22 @@
/**
* mock return callback(null, null).
*
* @param {Object} mod, module object

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"

Check warning on line 233 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, timeout". Got "mod,, method,, [timeout],"
* @param {String} method, mock module object method name.
* @param {Number} [timeout], mock async callback timeout, default is 0.
*/
function mockEmpty(mod: any, method: string, timeout?: number) {
function mockEmpty(mod: any, method: string | symbol, timeout?: number) {
return mockDatas(mod, method, [ null ], timeout);
}

/**
* spy a function
* @param {Object} mod, module object

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 243 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"
* @param {String} method, mock module object method name.
*/
function spy(mod: any, method: string) {
function spy(mod: any, method: string | symbol) {
if (typeof mod[method] !== 'function') {
throw new Error(`spy target ${method} is not a function`);
throw new Error(`spy target ${String(method)} is not a function`);

Check warning on line 248 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L248

Added line #L248 was not covered by tests
}
const originalFn = mod[method];
const wrap = function proxy(this: any, ...args: any[]) {
Expand All @@ -257,12 +257,12 @@
/**
* mock function sync throw error
*
* @param {Object} mod, module object

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"

Check warning on line 260 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, error, props". Got "mod,, method,, error,, [props],"
* @param {String} method, mock module object method name.
* @param {String|Error} error, error string message or error instance.
* @param {Object} [props], error properties
*/
function syncError(mod: any, method: string, error?: MockError, props?: Record<string, any>) {
function syncError(mod: any, method: string | symbol, error?: MockError, props?: Record<string, any>) {
error = _createError(error, props);
mock(mod, method, () => {
throw error;
Expand All @@ -272,11 +272,11 @@
/**
* mock function sync return data
*
* @param {Object} mod, module object

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"

Check warning on line 275 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method, data". Got "mod,, method,, data,"
* @param {String} method, mock module object method name.
* @param {Object} data, return data.
*/
function syncData(mod: any, method: string, data?: any) {
function syncData(mod: any, method: string | symbol, data?: any) {
mock(mod, method, () => {
return data;
});
Expand All @@ -285,10 +285,10 @@
/**
* mock function sync return nothing
*
* @param {Object} mod, module object

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"

Check warning on line 288 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "mod, method". Got "mod,, method,"
* @param {String} method, mock module object method name.
*/
function syncEmpty(mod: any, method: string) {
function syncEmpty(mod: any, method: string | symbol) {
return syncData(mod, method);
}

Expand Down Expand Up @@ -337,7 +337,7 @@

/**
* Mock http.request().
* @param {String|RegExp|Object} url, request url path.

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 23)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18.19.0)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"

Check warning on line 340 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Expected @param names to be "url, data, headers, delay". Got "url,, data,, headers,, [delay],"
* If url is Object, should be {url: $url, host: $host}
* @param {String|Buffer|ReadStream} data, mock response data.
* If data is Array, then res will emit `data` event many times.
Expand Down Expand Up @@ -581,7 +581,7 @@
/**
* mock class method from instance
*/
function classMethod(instance: any, property: string, value?: any) {
function classMethod(instance: any, property: PropertyKey, value?: any) {
mock(instance.constructor.prototype, property, value);
}

Expand Down
26 changes: 20 additions & 6 deletions test/mm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,23 +763,37 @@ describe('test/mm.test.js', () => {
});
});

describe('mm()', function() {

describe('mm(), mock()', function() {
it('should mock process.env.KEY work', function() {
const orginalEnv = process.env.NODE_ENV;
const originalEnv = process.env.NODE_ENV;
mm(process.env, 'NODE_ENV', 'test2');
process.env.NODE_ENV!.should.equal('test2');
mm.restore();

assert(process.env.NODE_ENV === orginalEnv);
assert(process.env.NODE_ENV === originalEnv);

mm(process.env, 'NODE_ENV', 'test2');
process.env.NODE_ENV!.should.equal('test2');
mm(process.env, 'NODE_ENV', 'production');
process.env.NODE_ENV!.should.equal('production');
mm.restore();

assert(process.env.NODE_ENV === orginalEnv);
assert(process.env.NODE_ENV === originalEnv);
});

it('should mock Symbol property work', () => {
const foo = Symbol('foo');
const data = { [foo]: 'bar' };
assert.equal(data[foo], 'bar');
mm(data, foo, 'bar1');
assert.equal(data[foo], 'bar1');
});

it('should mock number property work', () => {
const data = { 1: 'bar' };
assert.equal(data[1], 'bar');
mm(data, 1, 'bar1');
assert.equal(data[1], 'bar1');
});

it('should mm() just like muk()', function(done) {
Expand Down Expand Up @@ -830,7 +844,7 @@ describe('test/mm.test.js', () => {
});
});

it('shoud mock function with property', () => {
it('should mock function with property', () => {
const NativeDate = Date;
const mockNow = function(date: any) {
const NewDate = function(...args: any[]) {
Expand Down
Loading