You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
782 B
33 lines
782 B
2 years ago
|
var es = require('../')
|
||
|
, it = require('it-is').style('colour')
|
||
|
|
||
|
exports ['es.parse() writes parsing errors with console.error'] = function (test) {
|
||
|
var parseStream = es.parse()
|
||
|
var oldConsoleError = console.error
|
||
|
console.error = function () {
|
||
|
console.error = oldConsoleError
|
||
|
it(arguments.length > 0).ok()
|
||
|
test.done()
|
||
|
}
|
||
|
|
||
|
// bare word is not valid JSON
|
||
|
parseStream.write('A')
|
||
|
}
|
||
|
|
||
|
exports ['es.parse({error: true(thy)}) emits error events from parsing'] = function (test) {
|
||
|
var parseStream = es.parse({error: 1})
|
||
|
var expectedError
|
||
|
try {
|
||
|
JSON.parse('A')
|
||
|
} catch(e) {
|
||
|
expectedError = e
|
||
|
}
|
||
|
|
||
|
parseStream.on('error', function (e) {
|
||
|
it(e).deepEqual(expectedError)
|
||
|
process.nextTick(function () {
|
||
|
test.done()
|
||
|
})
|
||
|
}).write('A')
|
||
|
}
|