1 | 'use strict';
|
2 |
|
3 | var test = require('tape');
|
4 | var quote = require('../').quote;
|
5 |
|
6 | test('quote', function (t) {
|
7 | t.equal(quote(['a', 'b', 'c d']), 'a b \'c d\'');
|
8 | t.equal(
|
9 | quote(['a', 'b', "it's a \"neat thing\""]),
|
10 | 'a b "it\'s a \\"neat thing\\""'
|
11 | );
|
12 | t.equal(
|
13 | quote(['$', '`', '\'']),
|
14 | '\\$ \\` "\'"'
|
15 | );
|
16 | t.equal(quote([]), '');
|
17 | t.equal(quote(['a\nb']), "'a\nb'");
|
18 | t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'");
|
19 | t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"');
|
20 | t.equal(quote(['X#(){}*|][!']), 'X\\#\\(\\)\\{\\}\\*\\|\\]\\[\\!');
|
21 | t.equal(quote(['a\n#\nb']), "'a\n#\nb'");
|
22 | t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}');
|
23 | t.equal(quote(['a', 1, true, false]), 'a 1 true false');
|
24 | t.equal(quote(['a', 1, null, undefined]), 'a 1 null undefined');
|
25 | t.equal(quote(['a\\x']), 'a\\\\x');
|
26 | t.end();
|
27 | });
|
28 |
|
29 | test('quote ops', function (t) {
|
30 | t.equal(quote(['a', { op: '|' }, 'b']), 'a \\| b');
|
31 | t.equal(
|
32 | quote(['a', { op: '&&' }, 'b', { op: ';' }, 'c']),
|
33 | 'a \\&\\& b \\; c'
|
34 | );
|
35 | t.end();
|
36 | });
|
37 |
|
38 | test('quote windows paths', { skip: 'breaking change, disabled until 2.x' }, function (t) {
|
39 | var path = 'C:\\projects\\node-shell-quote\\index.js';
|
40 |
|
41 | t.equal(quote([path, 'b', 'c d']), 'C:\\projects\\node-shell-quote\\index.js b \'c d\'');
|
42 |
|
43 | t.end();
|
44 | });
|
45 |
|
46 | test("chars for windows paths don't break out", function (t) {
|
47 | var x = '`:\\a\\b';
|
48 | t.equal(quote([x]), '\\`\\:\\\\a\\\\b');
|
49 | t.end();
|
50 | });
|