ToUpperExpression.js 1.6 KB

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