ToLowerExpression.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. var assert = require("assert"),
  3. ToLowerExpression = require("../../../../lib/pipeline/expressions/ToLowerExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. module.exports = {
  6. "ToLowerExpression": {
  7. "constructor()": {
  8. "should not throw Error when constructing without args": function testConstructor(){
  9. assert.doesNotThrow(function(){
  10. new ToLowerExpression();
  11. });
  12. }
  13. },
  14. "#getOpName()": {
  15. "should return the correct op name; $toLower": function testOpName(){
  16. assert.equal(new ToLowerExpression().getOpName(), "$toLower");
  17. }
  18. },
  19. "#getFactory()": {
  20. "should return the constructor for this class": function factoryIsConstructor(){
  21. assert.strictEqual(new ToLowerExpression().getFactory(), undefined);
  22. }
  23. },
  24. "#evaluate()": {
  25. "should return the lowercase version of the string if there is a null character in the middle of the string": function testStuff(){
  26. assert.strictEqual(Expression.parseOperand({$toLower:"$a"}).evaluate({a:"a\0B"}), "a\0b");
  27. },
  28. "should return the lowercase version of the string if there is a null character at the beginning of the string": function testStuff(){
  29. assert.strictEqual(Expression.parseOperand({$toLower:"$a"}).evaluate({a:"\0aB"}), "\0ab");
  30. },
  31. "should return the lowercase version of the string if there is a null character at the end of the string": function testStuff(){
  32. assert.strictEqual(Expression.parseOperand({$toLower:"$a"}).evaluate({a:"aB\0"}), "ab\0");
  33. }
  34. }
  35. }
  36. };
  37. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);