{"size": 3032, "ext": "js", "max_stars_repo_path": "api/src/lib/__tests__/is.test.js", "max_stars_repo_name": "elboqueronpaco/cms-digitalpaco", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/src/lib/__tests__/is.test.js", "max_issues_repo_name": "elboqueronpaco/cms-digitalpaco", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/src/lib/__tests__/is.test.js", "max_forks_repo_name": "elboqueronpaco/cms-digitalpaco", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.1379310345, "max_line_length": 117, "alphanum_fraction": 0.5903693931}
import { isArray, isDefined, isFunction, isJson, isNumber, isObject, isPassword, isString, isUndefined } from '../is'
const Jsonstr = JSON.stringify
describe('#isArray', () => {
  it('should return true if is an Array', () => {
    expect(isArray([1, 2, 3])).toBe(true)
  })
  it('should  return if is not an Array', () => {
    expect(isArray({
      bar: 'bar',
      foo: 'foo'
    })).toBe(false)
  });
})

describe('#isDefined', () => {
  it('should return true if a variable is defined', () => {
    const test = 'test'
    expect(isDefined(test)).toBe(true)
  })
  it('should  return false if a variabe is undefined', () => {
    let test
    expect(isDefined(test)).toBe(false)
  })
})
describe('#isFunction', () => {
  it('shold be true if variable is a function', () => {
    const test = () => 'bar'
    expect(isFunction(test)).toBe(true)
  })
  it('should be false if variable is a function', () => {
    const test = 'bar'
    expect(isFunction(test)).toBe(false)
  })
})

describe('#isJson', () => {
  it('should be true if a varible is a valid json', () => {
    const test = Jsonstr({
      foo: {
        bar: true
      }
    })
    expect(isJson(test)).toBe(true)
  })
  it('should be false if a variable is a valid json', () => {
    expect(isJson(null)).toBe(false)
    expect(isJson('test')).toBe(false)
  })
})

describe('#isNumber', () => {
  it('should be true if a variable is a number', () => {
    expect(isNumber(-1)).toBe(true)
    expect(isNumber(0)).toBe(true)
    expect(isNumber(1)).toBe(true)
  })

  it('should be false if a variable is not a number', () => {
    expect(isNumber(true)).toBe(false)
    expect(isNumber(false)).toBe(false)
    expect(isNumber('O')).toBe(false)
  })
})

describe('#isObject', () => {
  it('should return true if a variable is object', () => {
    const test = {
      foo: 'Foo'
    }

    expect(isObject(test)).toBe(true)
  })

  it('should return false if a variable is not an object', () => {
    const test = ['Foo']
    expect(isObject(test)).toBe(false)
  })
})

describe('#isPassword', () => {
  it('should be true if a value is a valid password', () => {
    expect(isPassword('12345678')).toBe(true)
  })

  it('should be true if a value is not a valid password', () => {
    expect(isPassword('12345')).toBe(false)
  })
})

describe('#isString', () => {
  it('should be true if a variable is a string', () => {
    expect(isString('foo')).toBe(true)
    expect(isString('123')).toBe(true)
    expect(isString('true')).toBe(true)
  })

  it('should be false if a variable is not a string', () => {
    expect(isString(true)).toBe(false)
    expect(isString(false)).toBe(false)
    expect(isString(0)).toBe(false)
    expect(isString(1)).toBe(false)
  })
})

describe('#isUndefined', () => {
  it('should return true if a variable is undefined', () => {
    let test
    expect(isUndefined(test)).toBe(true)
  })

  it('should return false if a variable is not undefined', () => {
    const test = 'foo'
    expect(isUndefined(test)).toBe(false)
  })
})
