ToLowerExpression.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. "#evaluate()": {
  20. "should return the lowercase version of the string if there is a null character in the middle of the string": function testStuff() {
  21. assert.strictEqual(Expression.parseOperand({
  22. $toLower: "$a"
  23. }).evaluate({
  24. a: "a\0B"
  25. }), "a\0b");
  26. },
  27. "should return the lowercase version of the string if there is a null character at the beginning of the string": function testStuff() {
  28. assert.strictEqual(Expression.parseOperand({
  29. $toLower: "$a"
  30. }).evaluate({
  31. a: "\0aB"
  32. }), "\0ab");
  33. },
  34. "should return the lowercase version of the string if there is a null character at the end of the string": function testStuff() {
  35. assert.strictEqual(Expression.parseOperand({
  36. $toLower: "$a"
  37. }).evaluate({
  38. a: "aB\0"
  39. }), "ab\0");
  40. }
  41. }
  42. }
  43. };
  44. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);