How to use the expect-more.isObject function in expect-more

To help you get started, we’ve selected a few expect-more examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JamieMason / expect-more / packages / expect-more-jest / src / to-have-object.ts View on Github external
export const toHaveObjectMatcher = (received: any, propPath: string) =>
  createResult({
    message: () => `expected ${propPath} of ${received} to be object`,
    notMessage: () => `expected ${propPath} of ${received} not to be object`,
    pass: isObject(getIn(propPath.split('.'), received))
  });
github JamieMason / expect-more / packages / expect-more-jest / src / lib / gen.ts View on Github external
const isBranch = (locator: ILocator): boolean => isObject(unwrap(locator)) || isArray(unwrap(locator));
github JamieMason / expect-more / packages / expect-more-jest / src / to-be-object.ts View on Github external
export const toBeObjectMatcher = (received: any) =>
  createResult({
    message: () => `expected ${received} to be an object`,
    notMessage: () => `expected ${received} not to be an object`,
    pass: isObject(received)
  });
github JamieMason / expect-more / packages / expect-more-jest / src / lib / deep-reduce.ts View on Github external
const iterator = (value: any, path: PropName[]) => {
    memo = fn(memo, path, value);
    if (isArray(value)) {
      for (let i = 0, len = value.length; i < len; i++) {
        iterator(value[i], path.concat(i));
      }
    } else if (isObject(value)) {
      for (const key in value) {
        if (value.hasOwnProperty(key)) {
          iterator(value[key], path.concat(key));
        }
      }
    }
    return memo;
  };
  return iterator(collection, []);
github JamieMason / expect-more / packages / expect-more-jest / src / lib / gen.ts View on Github external
const mutateDescendant = (memo: any[], path: PropName[]): any[] => {
    if (path.length) {
      const clone = JSON.parse(original);
      const locator = locateDescendant(path, clone);
      if (isObject(locator.owner)) {
        mutateObject(locator as IObjectLocator);
      } else if (isArray(locator.owner)) {
        mutateArray(locator as IArrayLocator);
      }
      if (JSON.stringify(clone) !== original) {
        memo.push(clone);
      }
    }
    return memo;
  };
  return deepReduce(collection, mutateDescendant, getInitialValue());