NotExpression_test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. if (!module.parent) return require.cache[__filename] = 0, (new(require("mocha"))()).addFile(__filename).ui("exports").run(process.exit);
  3. var assert = require("assert"),
  4. NotExpression = require("../../../../lib/pipeline/expressions/NotExpression"),
  5. Expression = require("../../../../lib/pipeline/expressions/Expression");
  6. exports.NotExpression = {
  7. "constructor()": {
  8. "should not throw Error when constructing without args": function() {
  9. assert.doesNotThrow(function(){
  10. new NotExpression();
  11. });
  12. },
  13. "should throw when constructing with args": function() {
  14. assert.throws(function(){
  15. new NotExpression(1);
  16. });
  17. },
  18. },
  19. "#getOpName()": {
  20. "should return the correct op name; $not": function() {
  21. assert.equal(new NotExpression().getOpName(), "$not");
  22. },
  23. },
  24. "#evaluate()": {
  25. "should return false for a true input; false for true": function() {
  26. assert.strictEqual(Expression.parseOperand({$not:true}, {}).evaluateInternal({}), false);
  27. },
  28. "should return true for a false input; true for false": function() {
  29. assert.strictEqual(Expression.parseOperand({$not:false}, {}).evaluateInternal({}), true);
  30. },
  31. },
  32. };