forked from sindresorhus/strip-json-comments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
18 lines (16 loc) · 792 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';
var assert = require('assert');
var strip = require('./strip-json-comments');
it('should strip comments', function () {
assert.strictEqual(strip('//comment\n{"a":"b"}'), '\n{"a":"b"}');
assert.strictEqual(strip('/*//comment*/{"a":"b"}'), '{"a":"b"}');
assert.strictEqual(strip('{"a":"b"//comment\n}'), '{"a":"b"\n}');
assert.strictEqual(strip('{"a":"b"/*comment*/}'), '{"a":"b"}');
assert.strictEqual(strip('{"a"/*\n\n\ncomment\r\n*/:"b"}'), '{"a":"b"}');
});
it('should not strip comments inside strings', function () {
assert.strictEqual(strip('{"a":"b//c"}'), '{"a":"b//c"}');
assert.strictEqual(strip('{"a":"b/*c*/"}'), '{"a":"b/*c*/"}');
assert.strictEqual(strip('{"/*a":"b"}'), '{"/*a":"b"}');
assert.strictEqual(strip('{"\\"/*a":"b"}'), '{"\\"/*a":"b"}');
});