How to use the jest-get-type function in jest-get-type

To help you get started, we’ve selected a few jest-get-type 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 ChristopherChudzicki / math3d-react / client / src / utils / testing / matchers.js View on Github external
export function isNearlyEqual(a, b, config = {} ) {
  const {
    numDigits = 6,
    nSamples = 5,
    range = [1, 3]
  } = config

  if (getType(a) !== getType(b)) {
    return false
  }

  switch (getType(a)) {

    case 'number': {
      return Math.abs(a - b) <= 10 ** -numDigits
    }

    case 'array': {
      return a.length === b.length &&
        a.every((item, index) => isNearlyEqual(item, b[index], config))
    }

    case 'function': {
      // by using max arity, we allow that functions of different arity might be
      // nearly equal. For example, x => 5 and (x, y) => 5
      const arity = Math.max(a.length, b.length)
      const [min, max] = range
      const samples = genSamples(min, max, nSamples, arity)
github ChristopherChudzicki / math3d-react / client / src / utils / testing / matchers.js View on Github external
export function isNearlyEqual(a, b, config = {} ) {
  const {
    numDigits = 6,
    nSamples = 5,
    range = [1, 3]
  } = config

  if (getType(a) !== getType(b)) {
    return false
  }

  switch (getType(a)) {

    case 'number': {
      return Math.abs(a - b) <= 10 ** -numDigits
    }

    case 'array': {
      return a.length === b.length &&
        a.every((item, index) => isNearlyEqual(item, b[index], config))
    }

    case 'function': {
      // by using max arity, we allow that functions of different arity might be
github jest-community / jest-extended / src / matchers / toBeDate / predicate.js View on Github external
const isDate = value => getType(value) === 'date' && !isNaN(value);
github razumnyak / vue-div-100vh / src / vue100vh / convertStyle / convertStyle.js View on Github external
function throwOnBadArgs(givenStyle, windowHeight) {
  if (getType(givenStyle) !== 'object' && givenStyle !== undefined)
    throw Error(`style (the first argument) must be an object or undefined`);
  if (typeof windowHeight !== 'number' || windowHeight < 0)
    throw Error('Second argument (windowHeight) must be a non-negative number');
}

jest-get-type

A utility function to get the type of a value

MIT
Latest version published 8 months ago

Package Health Score

91 / 100
Full package analysis

Popular jest-get-type functions

Similar packages