MillisecondExpression.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. var assert = require("assert"),
  3. MillisecondExpression = require("../../../../lib/pipeline/expressions/MillisecondExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. module.exports = {
  6. "MillisecondExpression": {
  7. "constructor()": {
  8. "should not throw Error when constructing without args": function testConstructor() {
  9. assert.doesNotThrow(function() {
  10. new MillisecondExpression();
  11. });
  12. }
  13. },
  14. "#getOpName()": {
  15. "should return the correct op name; $millisecond": function testOpName(){
  16. assert.equal(new MillisecondExpression().getOpName(), "$millisecond");
  17. }
  18. },
  19. "#evaluate()": {
  20. "should return the current millisecond in the date; 456 for 2013-02-18 11:24:19 EST": function testStuff() {
  21. var input = [new Date("2013-02-18T11:24:19.456Z")];
  22. assert.strictEqual(Expression.parseExpression("$millisecond", input).evaluate({}), 456);
  23. // assert.strictEqual(Expression.parseOperand({
  24. // $millisecond: "$someDate"
  25. // }).evaluate({
  26. // someDate: new Date("2013-02-18T11:24:19.456Z")
  27. // }), 456);
  28. // }
  29. /*
  30. "should return the leap millisecond in the date; 60 for June 30, 2012 at 23:59:60 UTC": function testStuff(){
  31. assert.strictEqual(Expression.parseOperand({$millisecond:"$someDate"}).evaluate({someDate:new Date("June 30, 2012 at 23:59:60 UTC")}), 60);
  32. }
  33. */
  34. }
  35. }
  36. }
  37. };
  38. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);