source: frontend/node_modules/shell-quote/test/quote.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict';
2
3var test = require('tape');
4var quote = require('../').quote;
5
6test('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.equal(quote(['a"b']), '\'a"b\'');
27 t.equal(quote(['"a"b"']), '\'"a"b"\'');
28 t.equal(quote(['a\\"b']), '\'a\\"b\'');
29 t.equal(quote(['a\\b']), '\'a\\b\'');
30 t.end();
31});
32
33test('quote ops', function (t) {
34 t.equal(quote(['a', { op: '|' }, 'b']), 'a \\| b');
35 t.equal(
36 quote(['a', { op: '&&' }, 'b', { op: ';' }, 'c']),
37 'a \\&\\& b \\; c'
38 );
39 t.end();
40});
41
42test('quote windows paths', { skip: 'breaking change, disabled until 2.x' }, function (t) {
43 var path = 'C:\\projects\\node-shell-quote\\index.js';
44
45 t.equal(quote([path, 'b', 'c d']), 'C:\\projects\\node-shell-quote\\index.js b \'c d\'');
46
47 t.end();
48});
49
50test("chars for windows paths don't break out", function (t) {
51 var x = '`:\\a\\b';
52 t.equal(quote([x]), "'`:\\a\\b'");
53 t.end();
54});
55
56test('empty strings', function (t) {
57 t.equal(quote(['-x', '', 'y']), '-x \'\' y');
58
59 t.end();
60});
Note: See TracBrowser for help on using the repository browser.