SizeExpression.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. var assert = require("assert"),
  3. SizeExpression = require("../../../../lib/pipeline/expressions/SizeExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. module.exports = {
  6. "SizeExpression": {
  7. "constructor()": {
  8. "should throw Error when constructing without args": function testConstructor() {
  9. assert.throws(function() {
  10. new SizeExpression();
  11. });
  12. }
  13. },
  14. "#getOpName()": {
  15. "should return the correct op name; $size": function testOpName() {
  16. assert.equal(new SizeExpression("test").getOpName(), "$size");
  17. }
  18. },
  19. "#evaluateInternal()": {
  20. // New test not working
  21. "should return the size": function testSize() {
  22. assert.strictEqual(Expression.parseOperand({
  23. $size: ["$a"]
  24. }).evaluateInternal({
  25. a: [{a:1},{b:2}],
  26. b: [{c:3}]
  27. }), 4);
  28. }
  29. }
  30. }
  31. };
  32. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);