DayOfWeekExpression.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var assert = require("assert"),
  2. DayOfWeekExpression = require("../../../../lib/pipeline/expressions/DayOfWeekExpression"),
  3. Expression = require("../../../../lib/pipeline/expressions/Expression");
  4. module.exports = {
  5. "DayOfWeekExpression": {
  6. "constructor()": {
  7. "should not throw Error when constructing without args": function testConstructor(){
  8. assert.doesNotThrow(function(){
  9. new DayOfWeekExpression();
  10. });
  11. }
  12. },
  13. "#getOpName()": {
  14. "should return the correct op name; $dayOfWeek": function testOpName(){
  15. assert.equal(new DayOfWeekExpression().getOpName(), "$dayOfWeek");
  16. }
  17. },
  18. "#getFactory()": {
  19. "should return the constructor for this class": function factoryIsConstructor(){
  20. assert.strictEqual(new DayOfWeekExpression().getFactory(), undefined);
  21. }
  22. },
  23. "#evaluate()": {
  24. "should return day of week; 2 for 2013-02-18": function testStuff(){
  25. assert.strictEqual(Expression.parseOperand({$dayOfWeek:"$someDate"}).evaluate({someDate:new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")}), 2);
  26. }
  27. }
  28. }
  29. };
  30. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);