{"size": 1840, "ext": "js", "max_stars_repo_path": "test/specs/util/DataUtilsSpec.js", "max_stars_repo_name": "hedaktibo/recharts", "max_stars_repo_stars_event_min_datetime": "2015-10-30T08:09:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:15:16.000Z", "max_issues_repo_path": "test/specs/util/DataUtilsSpec.js", "max_issues_repo_name": "hedaktibo/recharts", "max_issues_repo_issues_event_min_datetime": "2016-01-15T21:24:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T10:14:42.000Z", "max_forks_repo_path": "test/specs/util/DataUtilsSpec.js", "max_forks_repo_name": "hedaktibo/recharts", "max_forks_repo_forks_event_min_datetime": "2016-01-06T13:48:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T16:15:16.000Z"}
{"max_stars_count": 19081, "max_issues_count": 2547, "max_forks_count": 1744, "avg_line_length": 30.6666666667, "max_line_length": 82, "alphanum_fraction": 0.6152173913}
import { expect } from 'chai';
import { scaleLinear, scaleBand } from 'd3-scale';
import { getPercentValue, getBandSizeOfAxis, getAnyElementOfObject,
  calculateDomainOfTicks, parseSpecifiedDomain, hasDuplicate, parseScale,
  getTicksOfScale, getValueByDataKey, mathSign, offsetSign
} from '../../../src/util/DataUtils';

describe('getPercentValue', () => {
  it('DataUtils.getPercentValue("25%", 1) should return 0.25 ', () => {
    expect(getPercentValue('25%', 1)).to.equal(0.25);
  });
  it('DataUtils.getPercentValue("25%", "a") should return 0 ', () => {
    expect(getPercentValue('25%', 'a')).to.equal(0);
  });
  it('DataUtils.getPercentValue(1)) should return 1', () => {
    expect(getPercentValue(1)).to.equal(1);
  });
  it('DataUtils.getPercentValue("120%", 100)) should return 120', () => {
    expect(getPercentValue('120%', 100)).to.equal(120);
  });

  it('DataUtils.getPercentValue("120%", 100, 0, true)) should return 100', () => {
    expect(getPercentValue('120%', 100, 0, true)).to.equal(100);
  });
});

describe('getAnyElementOfObject', () => {
  it('DataUtils.getAnyElementOfObject() should return null ', () => {
    expect(getAnyElementOfObject()).to.equal(null);
  });

  it('DataUtils.getAnyElementOfObject({}) should return null ', () => {
    expect(getAnyElementOfObject({})).to.equal(null);
  });
});

describe('hasDuplicate', () => {
  it('of an object should return false when input value is not an array', () => {
    expect(hasDuplicate({})).to.be.false;
  });

  it('of [12, 12] should return true', () => {
    expect(hasDuplicate([12, 12])).to.be.true;
  });
});

describe('mathSign', () => {

  it('(0)', () => {
    expect(mathSign(0)).to.equal(0);
  });

  it('(100)', () => {
    expect(mathSign(100)).to.equal(1);
  });

  it('(-100)', () => {
    expect(mathSign(-100)).to.equal(-1);
  });
});