DateToStringExpression.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. var assert = require("assert"),
  3. DateToStringExpression = require("../../../../lib/pipeline/expressions/DateToStringExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. //VariablesParseState = require("../../../../Lib/pipeline/expressions/VariablesParseState"),
  6. //VariablesIdGenerator = require("../../../../Lib/pipeline/expressions/VariablesIdGenerator");
  7. module.exports = {
  8. "DateToStringExpression": {
  9. "constructor()": {
  10. "should not throw Error when constructing with 2 args": function testConstructor() {
  11. assert.doesNotThrow(function() {
  12. new DateToStringExpression("%Y%m%d", "1/1/2014");
  13. });
  14. }
  15. },
  16. "#getOpName()" : {
  17. "should return the correct opName: $dateToString": function testOpName() {
  18. assert.equal(new DateToStringExpression("%Y%m%d", "1/1/2014").getOpName(), "$dateToString");
  19. }
  20. },
  21. "evaluateInternal1()" : {
  22. "should return the date to string": function evaluateInternal1() {
  23. //var input = ["%Y%m%d", new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")];
  24. //assert.strictEqual(DateToStringExpression.parse("$dateToString", input).evaluate({}), "2013/2/18");
  25. var dateToStringExpression = new DateToStringExpression().parse({$expr:{vars:["$dateToString", "%Y%m%d", new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")]}}, {});
  26. assert(dateToStringExpression);
  27. }
  28. }
  29. }
  30. }
  31. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);