How to use the expect-more.isArray 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-array.ts View on Github external
export const toHaveArrayMatcher = (received: any, propPath: string) =>
  createResult({
    message: () => `expected ${propPath} of ${received} to be an array`,
    notMessage: () => `expected ${propPath} of ${received} not to be an array`,
    pass: isArray(getIn(propPath.split('.'), 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 / to-be-array.ts View on Github external
export const toBeArrayMatcher = (received: any) =>
  createResult({
    message: () => `expected ${received} to be an array`,
    notMessage: () => `expected ${received} not to be an array`,
    pass: isArray(received)
  });
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());