项目原始demo,不改动
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.
 
 
 
 

61 Zeilen
1.5 KiB

  1. var assert = require('chai').assert,
  2. shell = require('..').shell;
  3. /**
  4. * Mocha BDD interface.
  5. */
  6. /** @name describe @function */
  7. /** @name it @function */
  8. /** @name before @function */
  9. /** @name after @function */
  10. /** @name beforeEach @function */
  11. /** @name afterEach @function */
  12. describe('shell', function() {
  13. describe('escape()', function() {
  14. var escape = shell.escape;
  15. it('Should wrap values with spaces in double quotes', function() {
  16. assert.equal(escape('asd abc'), '"asd abc"');
  17. });
  18. it('Should escape double quote "', function() {
  19. assert.equal(escape('"asd'), '\\"asd');
  20. });
  21. it("Should escape single quote '", function() {
  22. assert.equal(escape("'asd"), "\\'asd");
  23. });
  24. it('Should escape backslash \\', function() {
  25. assert.equal(escape('\\asd'), '\\\\asd');
  26. });
  27. it('Should escape dollar $', function() {
  28. assert.equal(escape('$asd'), '\\$asd');
  29. });
  30. it('Should escape backtick `', function() {
  31. assert.equal(escape('`asd'), '\\`asd');
  32. });
  33. });
  34. describe('unescape()', function() {
  35. var unescape = shell.unescape;
  36. it('Should strip double quotes at the both ends', function() {
  37. assert.equal(unescape('"asd"'), 'asd');
  38. });
  39. it('Should not strip escaped double quotes at the both ends', function() {
  40. assert.equal(unescape('\\"asd\\"'), '"asd"');
  41. });
  42. });
  43. });