ToUpperExpression.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. var assert = require("assert"),
  3. ToUpperExpression = require("../../../../lib/pipeline/expressions/ToUpperExpression"),
  4. Expression = require("../../../../lib/pipeline/expressions/Expression");
  5. module.exports = {
  6. "ToUpperExpression": {
  7. "constructor()": {
  8. "should not throw Error when constructing without args": function testConstructor() {
  9. assert.doesNotThrow(function() {
  10. new ToUpperExpression();
  11. });
  12. }
  13. },
  14. "#getOpName()": {
  15. "should return the correct op name; $toUpper": function testOpName() {
  16. assert.equal(new ToUpperExpression().getOpName(), "$toUpper");
  17. }
  18. },
  19. "#evaluateInternal()": {
  20. "should return the uppercase version of the string if there is a null character in the middle of the string": function testStuff() {
  21. assert.strictEqual(Expression.parseOperand({
  22. $toUpper: "$a"
  23. }).evaluateInternal({
  24. a: "a\0B"
  25. }), "A\0B");
  26. },
  27. "should return the uppercase version of the string if there is a null character at the beginning of the string": function testStuff() {
  28. assert.strictEqual(Expression.parseOperand({
  29. $toUpper: "$a"
  30. }).evaluateInternal({
  31. a: "\0aB"
  32. }), "\0AB");
  33. },
  34. "should return the uppercase version of the string if there is a null character at the end of the string": function testStuff() {
  35. assert.strictEqual(Expression.parseOperand({
  36. $toUpper: "$a"
  37. }).evaluateInternal({
  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);