25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
838 B

  1. import test from "ava";
  2. import formValidator from "../../src/services/form-validator";
  3. test("formValidator.increment()", t => {
  4. t.is(formValidator.increment(1, { min: 0, max: 10 }), 2);
  5. t.is(formValidator.increment(9, { min: 0, max: 10 }), 10);
  6. t.is(formValidator.increment(10, { min: 0, max: 10 }), 10);
  7. t.is(formValidator.increment(-1, { min: 0, max: 10 }), 0);
  8. t.is(formValidator.increment(-5, { min: 0, max: 10 }), 0);
  9. t.is(formValidator.increment(5, { min: 0 }), 6);
  10. });
  11. test("formValidator.decrement()", t => {
  12. t.is(formValidator.decrement(2, { min: 0, max: 10 }), 1);
  13. t.is(formValidator.decrement(1, { min: 0, max: 10 }), 0);
  14. t.is(formValidator.decrement(0, { min: 0, max: 10 }), 0);
  15. t.is(formValidator.decrement(-1, { min: 0, max: 10 }), 0);
  16. t.is(formValidator.decrement(15, { min: 0, max: 10 }), 10);
  17. });