SubtractExpression.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var assert = require("assert"),
  3. SubtractExpression = require("../../../../lib/pipeline/expressions/SubtractExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. module.exports = {
  6. "SubtractExpression": {
  7. "constructor()": {
  8. "should not throw Error when constructing without args": function testConstructor() {
  9. assert.doesNotThrow(function() {
  10. new SubtractExpression();
  11. });
  12. }
  13. },
  14. "#getOpName()": {
  15. "should return the correct op name; $subtract": function testOpName() {
  16. assert.equal(new SubtractExpression().getOpName(), "$subtract");
  17. }
  18. },
  19. "#evaluateInternal()": {
  20. "should return the result of subtraction between two numbers": function testStuff() {
  21. assert.strictEqual(Expression.parseOperand({
  22. $subtract: ["$a", "$b"]
  23. }).evaluateInternal({
  24. a: 35636364,
  25. b: -0.5656
  26. }), 35636364 - (-0.5656));
  27. }
  28. }
  29. }
  30. };
  31. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);