{"size": 1193, "ext": "js", "max_stars_repo_path": "src/sync/remove/drop.test.js", "max_stars_repo_name": "yeldiRium/gen-z", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/sync/remove/drop.test.js", "max_issues_repo_name": "yeldiRium/gen-z", "max_issues_repo_issues_event_min_datetime": "2020-02-14T18:20:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-26T03:09:15.000Z", "max_forks_repo_path": "src/sync/remove/drop.test.js", "max_forks_repo_name": "yeldiRium/gen-z", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 132, "max_forks_count": null, "avg_line_length": 25.9347826087, "max_line_length": 74, "alphanum_fraction": 0.6362112322}
const collect = require("../consume/collect");
const drop = require(".//drop");
const range = require("../create/range");

describe("sync.remove.drop", () => {
  it("drops n values from the start of the generator", () => {
    const sourceGenerator = range(10);

    const droppedGenerator = drop(5, sourceGenerator);

    const result = collect(droppedGenerator);
    expect(result).toStrictEqual([5, 6, 7, 8, 9]);
  });

  it("yields nothing, if the generator yields less than n values", () => {
    const sourceGenerator = range(4);

    const droppedGenerator = drop(5, sourceGenerator);

    const result = collect(droppedGenerator);
    expect(result).toStrictEqual([]);
  });

  it("is curried", () => {
    const sourceGenerator = range(4);

    const dropFive = drop(5);

    const droppedGenerator = dropFive(sourceGenerator);

    const result = collect(droppedGenerator);
    expect(result).toStrictEqual([]);
  });

  it("propagates errors", () => {
    const sourceGenerator = (function* () {
      yield 2;
      throw new Error("Blub.");
    })();

    const droppedGenerator = drop(1, sourceGenerator);

    expect(() => collect(droppedGenerator)).toThrow("Blub.");
  });
});
