MillisecondExpression.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. "#getFactory()": {
  20. "should return the constructor for this class": function factoryIsConstructor() {
  21. assert.strictEqual(new MillisecondExpression().getFactory(), undefined);
  22. }
  23. },
  24. "#evaluate()": {
  25. "should return the current millisecond in the date; 19 for 2013-02-18 11:24:19 EST": function testStuff() {
  26. assert.strictEqual(Expression.parseOperand({
  27. $millisecond: "$someDate"
  28. }).evaluate({
  29. someDate: new Date("2013-02-18T11:24:19.456Z")
  30. }), 456);
  31. }
  32. /*
  33. "should return the leap millisecond in the date; 60 for June 30, 2012 at 23:59:60 UTC": function testStuff(){
  34. assert.strictEqual(Expression.parseOperand({$millisecond:"$someDate"}).evaluate({someDate:new Date("June 30, 2012 at 23:59:60 UTC")}), 60);
  35. }
  36. */
  37. }
  38. }
  39. };
  40. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);