1 | 'use strict';
|
---|
2 |
|
---|
3 | var inspect = require('../');
|
---|
4 | var test = require('tape');
|
---|
5 |
|
---|
6 | test('quoteStyle option', function (t) {
|
---|
7 | t['throws'](function () { inspect(null, { quoteStyle: false }); }, 'false is not a valid value');
|
---|
8 | t['throws'](function () { inspect(null, { quoteStyle: true }); }, 'true is not a valid value');
|
---|
9 | t['throws'](function () { inspect(null, { quoteStyle: '' }); }, '"" is not a valid value');
|
---|
10 | t['throws'](function () { inspect(null, { quoteStyle: {} }); }, '{} is not a valid value');
|
---|
11 | t['throws'](function () { inspect(null, { quoteStyle: [] }); }, '[] is not a valid value');
|
---|
12 | t['throws'](function () { inspect(null, { quoteStyle: 42 }); }, '42 is not a valid value');
|
---|
13 | t['throws'](function () { inspect(null, { quoteStyle: NaN }); }, 'NaN is not a valid value');
|
---|
14 | t['throws'](function () { inspect(null, { quoteStyle: function () {} }); }, 'a function is not a valid value');
|
---|
15 |
|
---|
16 | t.equal(inspect('"', { quoteStyle: 'single' }), '\'"\'', 'double quote, quoteStyle: "single"');
|
---|
17 | t.equal(inspect('"', { quoteStyle: 'double' }), '"\\""', 'double quote, quoteStyle: "double"');
|
---|
18 |
|
---|
19 | t.equal(inspect('\'', { quoteStyle: 'single' }), '\'\\\'\'', 'single quote, quoteStyle: "single"');
|
---|
20 | t.equal(inspect('\'', { quoteStyle: 'double' }), '"\'"', 'single quote, quoteStyle: "double"');
|
---|
21 |
|
---|
22 | t.equal(inspect('`', { quoteStyle: 'single' }), '\'`\'', 'backtick, quoteStyle: "single"');
|
---|
23 | t.equal(inspect('`', { quoteStyle: 'double' }), '"`"', 'backtick, quoteStyle: "double"');
|
---|
24 |
|
---|
25 | t.end();
|
---|
26 | });
|
---|