{"size": 3567, "ext": "js", "max_stars_repo_path": "src/tests/number.rules.test.js", "max_stars_repo_name": "fossabot/v4f", "max_stars_repo_stars_event_min_datetime": "2019-02-06T23:31:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T15:07:53.000Z", "max_issues_repo_path": "src/tests/number.rules.test.js", "max_issues_repo_name": "fossabot/v4f", "max_issues_repo_issues_event_min_datetime": "2019-02-06T17:48:41.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-11T19:55:32.000Z", "max_forks_repo_path": "src/tests/number.rules.test.js", "max_forks_repo_name": "fossabot/v4f", "max_forks_repo_forks_event_min_datetime": "2019-02-06T02:48:50.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-28T01:10:56.000Z"}
{"max_stars_count": 64, "max_issues_count": 15, "max_forks_count": 8, "avg_line_length": 24.1013513514, "max_line_length": 81, "alphanum_fraction": 0.5214465938}
import {
  between,
  number,
  greater,
  greaterOrEquals,
  less,
  lessOrEquals,
  positive,
  negative,
  betweenOrEquals
} from "../rules/number";

describe("Test Number Rule", () => {
  const values = { valid: [3, 43, 5], invalid: [true, { a: 3 }, "3"] };
  const rule = number;

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Test Between 10 and 20 Rule", () => {
  const values = { valid: [11, 14], invalid: [9, 20, 10, 22] };

  const rule = n => between(10, 20, n);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Test BetweenOrEquals 10 and 20 Rule", () => {
  const values = { valid: [10, 20, 11, 14], invalid: [9, 5, 120, 22] };

  const rule = n => betweenOrEquals(10, 20, n);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Validate Greater than 10 Rule", () => {
  const values = { valid: [11, 22, 200], invalid: [10, 8, 0] };

  const rule = n => greater(n, 10);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Validate GreaterOrEquals to 10 Rule", () => {
  const values = { valid: [10, 22, 20, 99], invalid: [9, 5, 8] };

  const rule = n => greaterOrEquals(n, 10);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Validate Less 10 Rule", () => {
  const values = { valid: [9, 3, 4, 0], invalid: [10, 11, 34] };

  const rule = n => less(n, 10);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Validate LessOrEquals than 10 Rule", () => {
  const values = { valid: [9, 3, 4, 0, 10], invalid: [100, 11, 34] };

  const rule = n => lessOrEquals(n, 10);

  values.valid.forEach(n => {
    it(`value : ${n} should be true`, () => {
      expect(rule(n)).toBe(true);
    });
  });
  values.invalid.forEach(n => {
    it(`value : ${n} should be false`, () => {
      expect(rule(n)).toBe(false);
    });
  });
});

describe("Test Positive & Negative Rule", () => {
  const values = { valid: [0, 10, 3], invalid: [-2, -4, -10] };

  values.valid.forEach(n => {
    it(`value : ${n} should be true for positive and false for negative`, () => {
      expect(positive(n)).toBe(true);
      expect(negative(n)).toBe(false);
    });
  });

  values.invalid.forEach(n => {
    it(`value : ${n} should be false postrive and true negative`, () => {
      expect(positive(n)).toBe(false);
      expect(negative(n)).toBe(true);
    });
  });
});
