<commit_before>const chai = require('chai')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
const expect = chai.expect;

chai.use(sinonChai);

import checkPredicate from '../src/predicate'

describe("predicate types", function() {
  describe("lte", function() {
    let predicate;

    beforeEach(function() {
      predicate = {"foo": {"lte": 5}}
    });

    it("should not fire for values greater than", function() {
      const result = checkPredicate(predicate, {"foo": 10});
      expect(result).to.be.false;
    });

    it("should fire for values less than", function() {
      const result = checkPredicate(predicate, {"foo": 4});
      expect(result).to.be.true;
    });

    it("should fire for values equal to", function() {
      const result = checkPredicate(predicate, {"foo": 5});
      expect(result).to.be.true;
    });
  });

  describe("gte", function() {
    let predicate;
    
    beforeEach(function() {
      predicate = {"foo": {"gte": 5}}
    });

    it("should not fire for values less than", function() {
      const result = checkPredicate(predicate, {"foo": 4});
      expect(result).to.be.false;
    });

    it("should fire for values greater than", function() {
      const result = checkPredicate(predicate, {"foo": 6});
      expect(result).to.be.true;
    });

    it("should fire for values equal to", function() {
      const result = checkPredicate(predicate, {"foo": 5});
      expect(result).to.be.true;
    });
  });

  describe("exists", function() {
    describe("when asserting an object should exist", function() {
      let predicate;
      beforeEach(function() {
        predicate = {"foo": {"exists": true}};
      });

      it("should return true if the object exists", function() {
        const result = checkPredicate(predicate, {"foo": 5})
        expect(result).to.be.true;
      });

      it("should return false if the object is undefined", function() {
        const result = checkPredicate(predicate, {"foo": undefined})
        expect(result).to.be.false;

      });

      it("should return false if the object key doesn't exist", function() {
        const result = checkPredicate(predicate, {})
        expect(result).to.be.false;
      });
    });

    describe("when asserting an object shouldn't exist", function() {
      let predicate;
      beforeEach(function() {
        predicate = {"foo": {"exists": false}};
      });

      it("should return false if the object exists", function() {
        const result = checkPredicate(predicate, {"foo": 5})
        expect(result).to.be.false;
      });

      it("should return true if the object is undefined", function() {
        const result = checkPredicate(predicate, {"foo": undefined})
        expect(result).to.be.true;

      });

      it("should return true if the object key doesn't exist", function() {
        const result = checkPredicate(predicate, {})
        expect(result).to.be.true;
      });
    });    
  });
});

describe("combining multiple conditions", function() {
  let predicate;

  beforeEach(function() {
    predicate = {"foo": {"lte": 10, "gte": 5}}
  });

  it("should return true when both are true", function() {
    const result = checkPredicate(predicate, {"foo": 7});
    expect(result).to.be.true;
  });

  it("should not return true when only one is true", function() {
    const result1 = checkPredicate(predicate, {"foo": 4});
    expect(result1).to.be.false;

    const result2 = checkPredicate(predicate, {"foo": 11});
    expect(result2).to.be.false;
  });
});

describe("combining multiple variables", function() {
  let predicate;

  beforeEach(function() {
    predicate = {"foo": {"lte": 10},
                 "bar": {"gte": 5}};
  });

  it("should return true when both are true", function() {
    const result = checkPredicate(predicate, {"foo": 7, "bar": 7});
    expect(result).to.be.false;
  });

  it("should not return true when only one is true", function() {
    const result1 = checkPredicate(predicate, {"foo": 4, "bar": 4});
    expect(result1).to.be.false;

    const result2 = checkPredicate(predicate, {"foo": 11, "bar": 11});
    expect(result2).to.be.false;
  });
});<commit_msg>Fix incorrect test<commit_after>const chai = require('chai')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
const expect = chai.expect;

chai.use(sinonChai);

import checkPredicate from '../src/predicate'

describe("predicate types", function() {
  describe("lte", function() {
    let predicate;

    beforeEach(function() {
      predicate = {"foo": {"lte": 5}}
    });

    it("should not fire for values greater than", function() {
      const result = checkPredicate(predicate, {"foo": 10});
      expect(result).to.be.false;
    });

    it("should fire for values less than", function() {
      const result = checkPredicate(predicate, {"foo": 4});
      expect(result).to.be.true;
    });

    it("should fire for values equal to", function() {
      const result = checkPredicate(predicate, {"foo": 5});
      expect(result).to.be.true;
    });
  });

  describe("gte", function() {
    let predicate;
    
    beforeEach(function() {
      predicate = {"foo": {"gte": 5}}
    });

    it("should not fire for values less than", function() {
      const result = checkPredicate(predicate, {"foo": 4});
      expect(result).to.be.false;
    });

    it("should fire for values greater than", function() {
      const result = checkPredicate(predicate, {"foo": 6});
      expect(result).to.be.true;
    });

    it("should fire for values equal to", function() {
      const result = checkPredicate(predicate, {"foo": 5});
      expect(result).to.be.true;
    });
  });

  describe("exists", function() {
    describe("when asserting an object should exist", function() {
      let predicate;
      beforeEach(function() {
        predicate = {"foo": {"exists": true}};
      });

      it("should return true if the object exists", function() {
        const result = checkPredicate(predicate, {"foo": 5})
        expect(result).to.be.true;
      });

      it("should return false if the object is undefined", function() {
        const result = checkPredicate(predicate, {"foo": undefined})
        expect(result).to.be.false;

      });

      it("should return false if the object key doesn't exist", function() {
        const result = checkPredicate(predicate, {})
        expect(result).to.be.false;
      });
    });

    describe("when asserting an object shouldn't exist", function() {
      let predicate;
      beforeEach(function() {
        predicate = {"foo": {"exists": false}};
      });

      it("should return false if the object exists", function() {
        const result = checkPredicate(predicate, {"foo": 5})
        expect(result).to.be.false;
      });

      it("should return true if the object is undefined", function() {
        const result = checkPredicate(predicate, {"foo": undefined})
        expect(result).to.be.true;

      });

      it("should return true if the object key doesn't exist", function() {
        const result = checkPredicate(predicate, {})
        expect(result).to.be.true;
      });
    });    
  });
});

describe("combining multiple conditions", function() {
  let predicate;

  beforeEach(function() {
    predicate = {"foo": {"lte": 10, "gte": 5}}
  });

  it("should return true when both are true", function() {
    const result = checkPredicate(predicate, {"foo": 7});
    expect(result).to.be.true;
  });

  it("should not return true when only one is true", function() {
    const result1 = checkPredicate(predicate, {"foo": 4});
    expect(result1).to.be.false;

    const result2 = checkPredicate(predicate, {"foo": 11});
    expect(result2).to.be.false;
  });
});

describe("combining multiple variables", function() {
  let predicate;

  beforeEach(function() {
    predicate = {"foo": {"lte": 10},
                 "bar": {"gte": 5}};
  });

  it("should return true when both are true", function() {
    const result = checkPredicate(predicate, {"foo": 7, "bar": 7});
    expect(result).to.be.true;
  });

  it("should not return true when only one is true", function() {
    const result1 = checkPredicate(predicate, {"foo": 4, "bar": 4});
    expect(result1).to.be.false;

    const result2 = checkPredicate(predicate, {"foo": 11, "bar": 11});
    expect(result2).to.be.false;
  });
});
{'fraction_non_alphanumeric': 0.16535433070866143, 'fraction_numerical': 0.00882844189930804, 'mean_word_length': 3.047802993722839, 'pattern_counts': {'":': 68, '<': 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': '2097326', 'n_tokens_mistral': 2581, 'n_tokens_neox': 2454, 'n_words': 680}