OrMatchExpression.js 755 B

123456789101112131415161718192021222324
  1. "use strict";
  2. var assert = require("assert"),
  3. OrMatchExpression = require("../../../../lib/pipeline/matcher/OrMatchExpression"),
  4. GTEMatchExpression = require("../../../../lib/pipeline/matcher/GTEMatchExpression");
  5. module.exports = {
  6. "OrMatchExpression": {
  7. "Should not match with 0 clauses": function (){
  8. var op = new OrMatchExpression();
  9. assert.ok( ! op.matches(5, '{$or: []}, 5'));
  10. },
  11. "Should match with a single matching clause": function() {
  12. var op = new OrMatchExpression();
  13. var gt = new GTEMatchExpression();
  14. gt.init('', 5);
  15. op.add(gt);
  16. assert.ok( op.matches(6) , '{$or: [{$gte: 5}]}, 6');
  17. }
  18. }
  19. }
  20. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);