{"size": 683, "ext": "js", "max_stars_repo_path": "__tests__/dataHas.js", "max_stars_repo_name": "risan/helpers", "max_stars_repo_stars_event_min_datetime": "2020-02-14T16:42:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T17:16:13.000Z", "max_issues_repo_path": "__tests__/dataHas.js", "max_issues_repo_name": "risan/helpers", "max_issues_repo_issues_event_min_datetime": "2020-06-02T06:39:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T23:32:56.000Z", "max_forks_repo_path": "__tests__/dataHas.js", "max_forks_repo_name": "risan/helpers", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 37.9444444444, "max_line_length": 65, "alphanum_fraction": 0.5636896047}
/* global expect:false, test:false */
import { dataHas } from '../src';

test('it returns true if path exist', () => {
  expect(dataHas({ foo: 'bar' }, 'foo')).toBe(true);
  expect(dataHas({ foo: { bar: 'baz' } }, 'foo.bar')).toBe(true);
  expect(dataHas([1, 2, 3], '[1]')).toBe(true);
  expect(dataHas({ foo: [1, 2, 3] }, 'foo.[1]')).toBe(true);
  expect(dataHas([{}, { id: 123 }], '[1].id')).toBe(true);
  expect(dataHas({ foo: null }, 'foo')).toBe(true);
  expect(dataHas({ foo: undefined }, 'foo')).toBe(true);
});

test('it returns false if path does not exist', () => {
  expect(dataHas({ foo: 'bar' }, 'baz')).toBe(false);
  expect(dataHas([1, 2, 3], '[3]')).toBe(false);
});
