Replace deprecated `assert.equal` with `assert.strictEqual`
This commit is contained in:
parent
e5169018c5
commit
df952ac61d
|
@ -6,91 +6,91 @@ describe('util', function () {
|
||||||
describe('sanitize', function () {
|
describe('sanitize', function () {
|
||||||
|
|
||||||
it('should leave valid JSON as is', function () {
|
it('should leave valid JSON as is', function () {
|
||||||
assert.equal(util.sanitize('{"a":2}'), '{"a":2}');
|
assert.strictEqual(util.sanitize('{"a":2}'), '{"a":2}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace JavaScript with JSON', function () {
|
it('should replace JavaScript with JSON', function () {
|
||||||
assert.equal(util.sanitize('{a:2}'), '{"a":2}');
|
assert.strictEqual(util.sanitize('{a:2}'), '{"a":2}');
|
||||||
assert.equal(util.sanitize('{a: 2}'), '{"a": 2}');
|
assert.strictEqual(util.sanitize('{a: 2}'), '{"a": 2}');
|
||||||
assert.equal(util.sanitize('{\n a: 2\n}'), '{\n "a": 2\n}');
|
assert.strictEqual(util.sanitize('{\n a: 2\n}'), '{\n "a": 2\n}');
|
||||||
assert.equal(util.sanitize('{\'a\':2}'), '{"a":2}');
|
assert.strictEqual(util.sanitize('{\'a\':2}'), '{"a":2}');
|
||||||
assert.equal(util.sanitize('{a:\'foo\'}'), '{"a":"foo"}');
|
assert.strictEqual(util.sanitize('{a:\'foo\'}'), '{"a":"foo"}');
|
||||||
assert.equal(util.sanitize('{a:\'foo\',b:\'bar\'}'), '{"a":"foo","b":"bar"}');
|
assert.strictEqual(util.sanitize('{a:\'foo\',b:\'bar\'}'), '{"a":"foo","b":"bar"}');
|
||||||
|
|
||||||
// should leave string content untouched
|
// should leave string content untouched
|
||||||
assert.equal(util.sanitize('"{a:b}"'), '"{a:b}"');
|
assert.strictEqual(util.sanitize('"{a:b}"'), '"{a:b}"');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add/remove escape characters', function () {
|
it('should add/remove escape characters', function () {
|
||||||
assert.equal(util.sanitize('"foo\'bar"'), '"foo\'bar"');
|
assert.strictEqual(util.sanitize('"foo\'bar"'), '"foo\'bar"');
|
||||||
assert.equal(util.sanitize('"foo\\"bar"'), '"foo\\"bar"');
|
assert.strictEqual(util.sanitize('"foo\\"bar"'), '"foo\\"bar"');
|
||||||
assert.equal(util.sanitize('\'foo"bar\''), '"foo\\"bar"');
|
assert.strictEqual(util.sanitize('\'foo"bar\''), '"foo\\"bar"');
|
||||||
assert.equal(util.sanitize('\'foo\\\'bar\''), '"foo\'bar"');
|
assert.strictEqual(util.sanitize('\'foo\\\'bar\''), '"foo\'bar"');
|
||||||
assert.equal(util.sanitize('"foo\\\'bar"'), '"foo\'bar"');
|
assert.strictEqual(util.sanitize('"foo\\\'bar"'), '"foo\'bar"');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace special white characters', function () {
|
it('should replace special white characters', function () {
|
||||||
assert.equal(util.sanitize('{"a":\u00a0"foo\u00a0bar"}'), '{"a": "foo\u00a0bar"}');
|
assert.strictEqual(util.sanitize('{"a":\u00a0"foo\u00a0bar"}'), '{"a": "foo\u00a0bar"}');
|
||||||
assert.equal(util.sanitize('{"a":\u2009"foo"}'), '{"a": "foo"}');
|
assert.strictEqual(util.sanitize('{"a":\u2009"foo"}'), '{"a": "foo"}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should escape unescaped control characters', function () {
|
it('should escape unescaped control characters', function () {
|
||||||
assert.equal(util.sanitize('"hello\bworld"'), '"hello\\bworld"')
|
assert.strictEqual(util.sanitize('"hello\bworld"'), '"hello\\bworld"')
|
||||||
assert.equal(util.sanitize('"hello\fworld"'), '"hello\\fworld"')
|
assert.strictEqual(util.sanitize('"hello\fworld"'), '"hello\\fworld"')
|
||||||
assert.equal(util.sanitize('"hello\nworld"'), '"hello\\nworld"')
|
assert.strictEqual(util.sanitize('"hello\nworld"'), '"hello\\nworld"')
|
||||||
assert.equal(util.sanitize('"hello\rworld"'), '"hello\\rworld"')
|
assert.strictEqual(util.sanitize('"hello\rworld"'), '"hello\\rworld"')
|
||||||
assert.equal(util.sanitize('"hello\tworld"'), '"hello\\tworld"')
|
assert.strictEqual(util.sanitize('"hello\tworld"'), '"hello\\tworld"')
|
||||||
assert.equal(util.sanitize('{"value\n": "dc=hcm,dc=com"}'), '{"value\\n": "dc=hcm,dc=com"}')
|
assert.strictEqual(util.sanitize('{"value\n": "dc=hcm,dc=com"}'), '{"value\\n": "dc=hcm,dc=com"}')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should replace left/right quotes', function () {
|
it('should replace left/right quotes', function () {
|
||||||
assert.equal(util.sanitize('\u2018foo\u2019'), '"foo"')
|
assert.strictEqual(util.sanitize('\u2018foo\u2019'), '"foo"')
|
||||||
assert.equal(util.sanitize('\u201Cfoo\u201D'), '"foo"')
|
assert.strictEqual(util.sanitize('\u201Cfoo\u201D'), '"foo"')
|
||||||
assert.equal(util.sanitize('\u0060foo\u00B4'), '"foo"')
|
assert.strictEqual(util.sanitize('\u0060foo\u00B4'), '"foo"')
|
||||||
});
|
});
|
||||||
|
|
||||||
it('remove comments', function () {
|
it('remove comments', function () {
|
||||||
assert.equal(util.sanitize('/* foo */ {}'), ' {}');
|
assert.strictEqual(util.sanitize('/* foo */ {}'), ' {}');
|
||||||
assert.equal(util.sanitize('/* foo */ {}'), ' {}');
|
assert.strictEqual(util.sanitize('/* foo */ {}'), ' {}');
|
||||||
assert.equal(util.sanitize('{a:\'foo\',/*hello*/b:\'bar\'}'), '{"a":"foo","b":"bar"}');
|
assert.strictEqual(util.sanitize('{a:\'foo\',/*hello*/b:\'bar\'}'), '{"a":"foo","b":"bar"}');
|
||||||
assert.equal(util.sanitize('{\na:\'foo\',//hello\nb:\'bar\'\n}'), '{\n"a":"foo",\n"b":"bar"\n}');
|
assert.strictEqual(util.sanitize('{\na:\'foo\',//hello\nb:\'bar\'\n}'), '{\n"a":"foo",\n"b":"bar"\n}');
|
||||||
|
|
||||||
// should not remove comments in string
|
// should not remove comments in string
|
||||||
assert.equal(util.sanitize('{"str":"/* foo */"}'), '{"str":"/* foo */"}');
|
assert.strictEqual(util.sanitize('{"str":"/* foo */"}'), '{"str":"/* foo */"}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should strip JSONP notation', function () {
|
it('should strip JSONP notation', function () {
|
||||||
// matching
|
// matching
|
||||||
assert.equal(util.sanitize('callback_123({});'), '{}');
|
assert.strictEqual(util.sanitize('callback_123({});'), '{}');
|
||||||
assert.equal(util.sanitize('callback_123([]);'), '[]');
|
assert.strictEqual(util.sanitize('callback_123([]);'), '[]');
|
||||||
assert.equal(util.sanitize('callback_123(2);'), '2');
|
assert.strictEqual(util.sanitize('callback_123(2);'), '2');
|
||||||
assert.equal(util.sanitize('callback_123("foo");'), '"foo"');
|
assert.strictEqual(util.sanitize('callback_123("foo");'), '"foo"');
|
||||||
assert.equal(util.sanitize('callback_123(null);'), 'null');
|
assert.strictEqual(util.sanitize('callback_123(null);'), 'null');
|
||||||
assert.equal(util.sanitize('callback_123(true);'), 'true');
|
assert.strictEqual(util.sanitize('callback_123(true);'), 'true');
|
||||||
assert.equal(util.sanitize('callback_123(false);'), 'false');
|
assert.strictEqual(util.sanitize('callback_123(false);'), 'false');
|
||||||
assert.equal(util.sanitize('/* foo bar */ callback_123 ({})'), '{}');
|
assert.strictEqual(util.sanitize('/* foo bar */ callback_123 ({})'), '{}');
|
||||||
assert.equal(util.sanitize('/* foo bar */ callback_123 ({})'), '{}');
|
assert.strictEqual(util.sanitize('/* foo bar */ callback_123 ({})'), '{}');
|
||||||
assert.equal(util.sanitize('/* foo bar */\ncallback_123({})'), '{}');
|
assert.strictEqual(util.sanitize('/* foo bar */\ncallback_123({})'), '{}');
|
||||||
assert.equal(util.sanitize('/* foo bar */ callback_123 ( {} )'), ' {} ');
|
assert.strictEqual(util.sanitize('/* foo bar */ callback_123 ( {} )'), ' {} ');
|
||||||
assert.equal(util.sanitize(' /* foo bar */ callback_123 ({}); '), '{}');
|
assert.strictEqual(util.sanitize(' /* foo bar */ callback_123 ({}); '), '{}');
|
||||||
assert.equal(util.sanitize('\n/* foo\nbar */\ncallback_123 ({});\n\n'), '{}');
|
assert.strictEqual(util.sanitize('\n/* foo\nbar */\ncallback_123 ({});\n\n'), '{}');
|
||||||
|
|
||||||
// non-matching
|
// non-matching
|
||||||
assert.equal(util.sanitize('callback abc({});'), 'callback abc({});');
|
assert.strictEqual(util.sanitize('callback abc({});'), 'callback abc({});');
|
||||||
assert.equal(util.sanitize('callback {}'), 'callback {}');
|
assert.strictEqual(util.sanitize('callback {}'), 'callback {}');
|
||||||
assert.equal(util.sanitize('callback({}'), 'callback({}');
|
assert.strictEqual(util.sanitize('callback({}'), 'callback({}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should strip trailing zeros', function () {
|
it('should strip trailing zeros', function () {
|
||||||
// matching
|
// matching
|
||||||
assert.equal(util.sanitize('[1,2,3,]'), '[1,2,3]');
|
assert.strictEqual(util.sanitize('[1,2,3,]'), '[1,2,3]');
|
||||||
assert.equal(util.sanitize('[1,2,3,\n]'), '[1,2,3\n]');
|
assert.strictEqual(util.sanitize('[1,2,3,\n]'), '[1,2,3\n]');
|
||||||
assert.equal(util.sanitize('[1,2,3, \n ]'), '[1,2,3 \n ]');
|
assert.strictEqual(util.sanitize('[1,2,3, \n ]'), '[1,2,3 \n ]');
|
||||||
assert.equal(util.sanitize('{"a":2,}'), '{"a":2}');
|
assert.strictEqual(util.sanitize('{"a":2,}'), '{"a":2}');
|
||||||
|
|
||||||
// not matching
|
// not matching
|
||||||
assert.equal(util.sanitize('"[1,2,3,]"'), '"[1,2,3,]"');
|
assert.strictEqual(util.sanitize('"[1,2,3,]"'), '"[1,2,3,]"');
|
||||||
assert.equal(util.sanitize('"{a:2,}"'), '"{a:2,}"');
|
assert.strictEqual(util.sanitize('"{a:2,}"'), '"{a:2,}"');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -141,23 +141,23 @@ describe('util', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
it('happy flows - row and column in range', function () {
|
it('happy flows - row and column in range', function () {
|
||||||
assert.equal(util.getIndexForPosition(el, 1, 1), 0);
|
assert.strictEqual(util.getIndexForPosition(el, 1, 1), 0);
|
||||||
assert.equal(util.getIndexForPosition(el, 2, 1), 124);
|
assert.strictEqual(util.getIndexForPosition(el, 2, 1), 124);
|
||||||
assert.equal(util.getIndexForPosition(el, 3, 8), 239);
|
assert.strictEqual(util.getIndexForPosition(el, 3, 8), 239);
|
||||||
assert.equal(util.getIndexForPosition(el, 4, 22), 356);
|
assert.strictEqual(util.getIndexForPosition(el, 4, 22), 356);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('if range exceeds it should be considered as if it is last row or column length', function () {
|
it('if range exceeds it should be considered as if it is last row or column length', function () {
|
||||||
assert.equal(util.getIndexForPosition(el, 1, 100000), 123);
|
assert.strictEqual(util.getIndexForPosition(el, 1, 100000), 123);
|
||||||
assert.equal(util.getIndexForPosition(el, 100000, 1), 335);
|
assert.strictEqual(util.getIndexForPosition(el, 100000, 1), 335);
|
||||||
assert.equal(util.getIndexForPosition(el, 100000, 100000), 445);
|
assert.strictEqual(util.getIndexForPosition(el, 100000, 100000), 445);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('missing or wrong input sould return -1', function () {
|
it('missing or wrong input sould return -1', function () {
|
||||||
assert.equal(util.getIndexForPosition(el), -1);
|
assert.strictEqual(util.getIndexForPosition(el), -1);
|
||||||
assert.equal(util.getIndexForPosition(el, undefined, 1), -1);
|
assert.strictEqual(util.getIndexForPosition(el, undefined, 1), -1);
|
||||||
assert.equal(util.getIndexForPosition(el, 1, undefined), -1);
|
assert.strictEqual(util.getIndexForPosition(el, 1, undefined), -1);
|
||||||
assert.equal(util.getIndexForPosition(el, -2, -2), -1);
|
assert.strictEqual(util.getIndexForPosition(el, -2, -2), -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue