{"size": 784, "ext": "js", "max_stars_repo_path": "tests/uniq.to_.spec.js", "max_stars_repo_name": "nyinyithann/Uniq.js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/uniq.to_.spec.js", "max_issues_repo_name": "nyinyithann/Uniq.js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/uniq.to_.spec.js", "max_forks_repo_name": "nyinyithann/Uniq.js", "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.1333333333, "max_line_length": 76, "alphanum_fraction": 0.5395408163}
import { Uniq } from '../src/index';

describe('toArray() | toMap()', () => {
  test('throw exception if this is null or undefined', () => {
    const toArray = Uniq.prototype.toArray;
    const toMap = Uniq.prototype.toMap;

    expect(() => toArray.call(null)).toThrow(TypeError);
    expect(() => toMap.call(null)).toThrow(TypeError);
  });

  test('should return correct result', () => {
    const toArray = Uniq.prototype.toArray;
    const toMap = Uniq.prototype.toMap;

    const uniq = Uniq.of(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 3, 3, 5);

    expect(toArray.call(uniq)).toStrictEqual([1, 2, 4, 3, 5]);
    expect(toMap.call(uniq)).toStrictEqual(
      new Map([
        [1, 1],
        [2, 2],
        [4, 4],
        [3, 3],
        [5, 5],
      ])
    );
  });
});
