UNPKG

879 BJavaScriptView Raw
1gt.module('quote');
2
3var quote = require('..');
4
5gt.test('quotes a string', function () {
6 gt.equal(quote(''), '""');
7 gt.equal(quote('foo'), '"foo"');
8 gt.equal(quote(quote('foo')), '"foo"');
9});
10
11gt.test('config object', function () {
12 var q = quote({ quotes: '*' });
13 gt.func(q, 'returns a function');
14 gt.equal(q('foo'), '*foo*');
15 gt.equal(q(q('foo')), '*foo*');
16});
17
18gt.test('different options works independently', function () {
19 var wildcards = quote({ quotes: '*' });
20 gt.equal(quote('foo'), '"foo"');
21 gt.equal(wildcards('foo'), '*foo*');
22 var ups = quote({ quotes: '^' });
23 gt.equal(ups('bar'), '^bar^');
24});
25
26gt.test('can be configured multiple times', function () {
27 gt.equal(quote('foo'), '"foo"');
28 var q = quote({ quotes: '^' });
29 gt.equal(q('bar'), '^bar^');
30 // not working yet
31 // q = q({ quotes: '$' });
32 // gt.equal(q('baz'), '$baz$');
33});