-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only emit errors once, since we abort on the first one
This is the reason for node-tar's test failure in Node v14
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const t = require('tap') | ||
const { Gzip } = require('../') | ||
|
||
t.test('only raise once if emitted before writing', t => { | ||
t.plan(1) | ||
|
||
const gz = new Gzip() | ||
|
||
// dirty hack to get at the internal handle | ||
const kHandle = Object.getOwnPropertySymbols(gz) | ||
.filter(sym => sym.toString() === 'Symbol(handle)')[0] | ||
|
||
gz.once('error', er => t.match(er, { message: 'zlib: fart' })) | ||
const handle = gz[kHandle] | ||
handle.emit('error', new Error('fart')) | ||
handle.emit('error', new Error('poop')) | ||
}) | ||
|
||
t.test('only raise once if emitted after writing', t => { | ||
t.plan(1) | ||
|
||
const gz = new Gzip() | ||
|
||
// dirty hack to get at the internal handle | ||
const kHandle = Object.getOwnPropertySymbols(gz) | ||
.filter(sym => sym.toString() === 'Symbol(handle)')[0] | ||
|
||
gz.once('error', er => t.match(er, { message: 'zlib: fart' })) | ||
|
||
gz.write('hello, ') | ||
|
||
const handle = gz[kHandle] | ||
handle.emit('error', new Error('fart')) | ||
handle.emit('error', new Error('poop')) | ||
}) | ||
|
||
t.test('only raise once if emitted after writing after emitting', t => { | ||
t.plan(1) | ||
|
||
const gz = new Gzip() | ||
|
||
// dirty hack to get at the internal handle | ||
const kHandle = Object.getOwnPropertySymbols(gz) | ||
.filter(sym => sym.toString() === 'Symbol(handle)')[0] | ||
|
||
gz.once('error', er => t.match(er, { message: 'zlib: fart' })) | ||
|
||
gz.write('hello, ') | ||
|
||
const handle = gz[kHandle] | ||
handle.emit('error', new Error('fart')) | ||
gz.write(' world') | ||
handle.emit('error', new Error('poop')) | ||
}) |