feat(jsdoc-test-matchers): add toBeArrayOfObjects, toBeNumber, toHaveMethod matchers

This commit is contained in:
Jeff Williams 2023-03-08 15:52:09 -08:00
parent e3386558e1
commit 4dfa5d7a0d
No known key found for this signature in database

View File

@ -94,6 +94,9 @@ const matcherFuncs = {
return !actual.some((item) => !_.isString(item));
},
toBeArrayOfObjects: (actual) => {
return _.isArray(actual) && !actual.some((item) => !_.isObject(item));
},
toBeBoolean: (actual) => {
return _.isBoolean(actual);
},
@ -125,6 +128,9 @@ const matcherFuncs = {
toBeNonEmptyString: (actual) => {
return _.isString(actual) && actual.length > 0;
},
toBeNumber: (actual) => {
return _.isNumber(actual);
},
toBeObject: (actual) => {
return _.isObject(actual);
},
@ -143,6 +149,9 @@ const matcherFuncs = {
toEndWith: (actual, expected) => {
return _.isString(actual) && _.isString(expected) && actual.endsWith(expected);
},
toHaveMethod: (actual, expected) => {
return _.isObject(actual) && _.isFunction(actual[expected]);
},
toHaveOwnProperty: (actual, expected) => {
return Object.hasOwn(actual, expected);
},