lundi 1 février 2021

how can test this function with jest?

I have a function that checks if there is a given cookie in the array

import Cookies from 'js-cookie'

const isNumberCookies = (numbers) => {
  if (!Array.isArray(numbers)) {
    return false
  }
  const number = Cookies.get('check_number') || ''
  return numbers.some((cookie) => number.includes(cookie))
}

export default isNumberCookies

How I can test it jest, I need to check that Cookies.get was called with the parameter check_number and just was called

Aucun commentaire:

Enregistrer un commentaire