NotExpression_test.js 1.2 KB

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