{"size": 1228, "ext": "js", "max_stars_repo_path": "test/utils/utils.spec.js", "max_stars_repo_name": "mperceval/moonpig-challenge", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/utils/utils.spec.js", "max_issues_repo_name": "mperceval/moonpig-challenge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/utils/utils.spec.js", "max_forks_repo_name": "mperceval/moonpig-challenge", "max_forks_repo_forks_event_min_datetime": "2020-07-03T20:39:33.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-03T20:39:33.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 25.5833333333, "max_line_length": 85, "alphanum_fraction": 0.5423452769}

import { expect } from 'chai';
import { isEmpty, truncate } from '../../js/utils/utils';

describe('Utils', () => {

  describe ('isEmpty', () => {

    it('parameter is undefined - returns true', () => {
      const result = isEmpty(undefined);
      expect(result).to.be.true;
    });

    it('parameter is null - returns true', () => {
      const result = isEmpty(null);
      expect(result).to.be.true;
    });

    it('parameter length is 0 - returns true', () => {
      const result = isEmpty('');
      expect(result).to.be.true;
    });

    it('valid string with length > 0 - return false', () => {
      const result = isEmpty('test value');
      expect(result).to.be.false;
    });
  });

  describe ('truncate', () => {

    it('string to truncate is empty - returns \'\'', () => {
      const result = truncate('', 5);
      expect(result).to.equal('');
    });

    it('string length < length parameter - return string', () => {
      const result = truncate('Test', 5);
      expect(result).to.equal('Test');
    });

    it('string length > length parameter - return truncated string with ...', () => {
      const result = truncate('Testing', 4);
      expect(result).to.equal('Test...');
    });
  });
});
