SecondExpression.js 1.3 KB

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