<commit_before>var should = chai.should();

describe("Draggable-number", function() {
  var input = document.createElement("input");

  describe("DraggableNumberElement.getLargestDelta", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return 0 if there is no difference", function() {
      var pos = {x: 142, y: 2145};
      var result = this.el.getLargestDelta(pos, pos);
      result.should.equal(0);
    });

    it("Should return the largest delta", function() {
      var posA = {x: 100, y: 200};
      var posB = {x: 142, y: 243};
      var result = this.el.getLargestDelta(posB, posA);
      result.should.equal(43);
    });

    it("Should return the largest delta even if the difference is negative", function() {
      var posA = {x: 100, y: -200};
      var posB = {x: 142, y: -243};
      var result = this.el.getLargestDelta(posB, posA);
      result.should.equal(-43);
    });
  });

  describe("DraggableNumberElement.getNumberOffset", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return 1 if delta is positive and there is no modifier", function() {
      var result = this.el.getNumberOffset(1, DraggableNumber.MODIFIER_NONE);
      result.should.equal(1);
    });

    it("Should return -1 if delta is negative and there is no modifier", function() {
      var result = this.el.getNumberOffset(-21, DraggableNumber.MODIFIER_NONE);
      result.should.equal(-1);
    });

    it("Should return 10 if delta is positive and there is a large modifier", function() {
      var result = this.el.getNumberOffset(17, DraggableNumber.MODIFIER_LARGE);
      result.should.equal(10);
    });

    it("Should return -10 if delta is negative and there is a large modifier", function() {
      var result = this.el.getNumberOffset(-1, DraggableNumber.MODIFIER_LARGE);
      result.should.equal(-10);
    });

    it("Should return 0.1 if delta is positive and there is a small modifier", function() {
      var result = this.el.getNumberOffset(19, DraggableNumber.MODIFIER_SMALL);
      result.should.equal(0.1);
    });

    it("Should return -0.1 if delta is negative and there is a small modifier", function() {
      var result = this.el.getNumberOffset(-142, DraggableNumber.MODIFIER_SMALL);
      result.should.equal(-0.1);
    });
  });

  describe("DraggableNumberElement.hasMovedEnough", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return false if difference between 2 mouse positions is less than 10", function() {
      var result = this.el.hasMovedEnough({x: 0, y: 42}, {x: 2, y: 43});
      result.should.equal(false);
    });
<commit_msg>add test for updateNumber method<commit_after>var should = chai.should();

describe("Draggable-number", function() {
  var input = document.createElement("input");

  describe("DraggableNumberElement.getLargestDelta", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return 0 if there is no difference", function() {
      var pos = {x: 142, y: 2145};
      var result = this.el.getLargestDelta(pos, pos);
      result.should.equal(0);
    });

    it("Should return the largest delta", function() {
      var posA = {x: 100, y: 200};
      var posB = {x: 142, y: 243};
      var result = this.el.getLargestDelta(posB, posA);
      result.should.equal(43);
    });

    it("Should return the largest delta even if the difference is negative", function() {
      var posA = {x: 100, y: -200};
      var posB = {x: 142, y: -243};
      var result = this.el.getLargestDelta(posB, posA);
      result.should.equal(-43);
    });
  });

  describe("DraggableNumberElement.getNumberOffset", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return 1 if delta is positive and there is no modifier", function() {
      var result = this.el.getNumberOffset(1, DraggableNumber.MODIFIER_NONE);
      result.should.equal(1);
    });

    it("Should return -1 if delta is negative and there is no modifier", function() {
      var result = this.el.getNumberOffset(-21, DraggableNumber.MODIFIER_NONE);
      result.should.equal(-1);
    });

    it("Should return 10 if delta is positive and there is a large modifier", function() {
      var result = this.el.getNumberOffset(17, DraggableNumber.MODIFIER_LARGE);
      result.should.equal(10);
    });

    it("Should return -10 if delta is negative and there is a large modifier", function() {
      var result = this.el.getNumberOffset(-1, DraggableNumber.MODIFIER_LARGE);
      result.should.equal(-10);
    });

    it("Should return 0.1 if delta is positive and there is a small modifier", function() {
      var result = this.el.getNumberOffset(19, DraggableNumber.MODIFIER_SMALL);
      result.should.equal(0.1);
    });

    it("Should return -0.1 if delta is negative and there is a small modifier", function() {
      var result = this.el.getNumberOffset(-142, DraggableNumber.MODIFIER_SMALL);
      result.should.equal(-0.1);
    });
  });

  describe("DraggableNumberElement.updateNumber", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      input.value = 32;
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should update the value", function() {
      this.el.updateNumber(10);
      this.el.value.should.equal(42);
    });

    it("Should update the input.value", function() {
      this.el.updateNumber(12);
      this.el.input.value.should.equal('44');
    });

    it("Should update the span.innerHTML", function() {
      this.el.updateNumber(8);
      this.el.span.innerHTML.should.equal('40');
    });

  });

  describe("DraggableNumberElement.hasMovedEnough", function() {
    beforeEach(function() {
      document.body.appendChild(input);
      this.el = new DraggableNumber.Element(input);
    });

    afterEach(function() {
      this.el.destroy();
      delete this.el;
      document.body.removeChild(input);
    });

    it("Should return false if difference between 2 mouse positions is less than 10", function() {
      var result = this.el.hasMovedEnough({x: 0, y: 42}, {x: 2, y: 43});
      result.should.equal(false);
    });

{'fraction_non_alphanumeric': 0.14076206140350878, 'fraction_numerical': 0.02288925438596491, 'mean_word_length': 3.0203856749311293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5371706', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2214, 'n_words': 545}