Skip to content

Commit 8a6f4f5

Browse files
committed
chore: fix deprecated methods and escaped strings in tests
1 parent abf97b2 commit 8a6f4f5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ t.test('parses JSON', t => {
2020
}).map(([name, obj]) => [name, JSON.stringify(obj)])
2121
t.plan(cases.length)
2222
for (const [name, data] of cases) {
23-
t.deepEqual(parseJson(data), JSON.parse(data), name)
23+
t.same(parseJson(data), JSON.parse(data), name)
2424
}
2525
})
2626

@@ -75,8 +75,8 @@ t.test('parses JSON if it is a Buffer, removing BOM bytes', t => {
7575
})
7676
const data = Buffer.from(str)
7777
const bom = Buffer.concat([Buffer.from([0xEF, 0xBB, 0xBF]), data])
78-
t.deepEqual(parseJson(data), JSON.parse(str))
79-
t.deepEqual(parseJson(bom), JSON.parse(str), 'strips the byte order marker')
78+
t.same(parseJson(data), JSON.parse(str))
79+
t.same(parseJson(bom), JSON.parse(str), 'strips the byte order marker')
8080
t.end()
8181
})
8282

@@ -119,7 +119,7 @@ t.test('throws SyntaxError for unexpected end of JSON', t => {
119119
t.throws(
120120
() => parseJson(data),
121121
{
122-
message: 'Unexpected end of JSON input while parsing "{\\\\"foo: bar}"',
122+
message: 'Unexpected end of JSON input while parsing "{\\"foo: bar}"',
123123
code: 'EJSONPARSE',
124124
position: 10,
125125
name: 'JSONParseError',
@@ -163,7 +163,7 @@ t.test('SyntaxError with less context (limited end)', t => {
163163
t.throws(
164164
() => parseJson(data, null, 2),
165165
{
166-
message: 'Unexpected token "a" \\(0x61\\) in JSON at position 0 while parsing near "ab..."',
166+
message: 'Unexpected token "a" (0x61) in JSON at position 0 while parsing near "ab..."',
167167
code: 'EJSONPARSE',
168168
position: 0,
169169
name: 'JSONParseError',
@@ -209,7 +209,7 @@ t.test('handles empty string helpfully', t => {
209209
})
210210

211211
t.test('json parse error class', t => {
212-
t.isa(parseJson.JSONParseError, 'function')
212+
t.type(parseJson.JSONParseError, 'function')
213213
// we already checked all the various index checking logic above
214214
const poop = new Error('poop')
215215
const fooShouldNotShowUpInStackTrace = () => {
@@ -242,10 +242,10 @@ t.test('parse without exception', t => {
242242
t.equal(parseJson.noExceptions(bad), undefined, 'does not throw')
243243
const obj = { this: 'is json' }
244244
const good = JSON.stringify(obj)
245-
t.deepEqual(parseJson.noExceptions(good), obj, 'parses json string')
245+
t.same(parseJson.noExceptions(good), obj, 'parses json string')
246246
const buf = Buffer.from(good)
247-
t.deepEqual(parseJson.noExceptions(buf), obj, 'parses json buffer')
247+
t.same(parseJson.noExceptions(buf), obj, 'parses json buffer')
248248
const bom = Buffer.concat([Buffer.from([0xEF, 0xBB, 0xBF]), buf])
249-
t.deepEqual(parseJson.noExceptions(bom), obj, 'parses json buffer with bom')
249+
t.same(parseJson.noExceptions(bom), obj, 'parses json buffer with bom')
250250
t.end()
251251
})

0 commit comments

Comments
 (0)