All files / molecule/pagination/src/customPropTypes isValidTotalPages.js

100% Statements 9/9
100% Branches 6/6
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14    1x 4x 4x 3x 2x     1x        
import {getMessageErrorNumber, getMessageErrorPositive} from './helpers.js'
 
const isValidTotalPages = (props, propName, componentName) => {
  const totalPages = props[propName]
  if (totalPages === undefined) return null
  if (typeof totalPages !== 'number') return new Error(getMessageErrorNumber({propName, componentName}))
  if (totalPages <= 0) return new Error(getMessageErrorPositive({propName, componentName}))
 
  // assume all ok
  return null
}
 
export default isValidTotalPages