GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: fix test cases for uncompress stream (#118) · node-modules/compressing@5f281d9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/zip
    • uncompress_stream.test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/zip/uncompress_stream.test.js‎

Copy file name to clipboardExpand all lines: test/zip/uncompress_stream.test.js
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,24 @@ describe('test/zip/uncompress_stream.test.js', () => {
193193
pump(sourceStream, uncompressStream, err => {
194194
assert(!err);
195195
const res = dircompare.compareSync(originalDir, destDir);
196-
assert(res.distinct === 0);
197-
assert(res.equal === 5);
196+
assert.equal(res.distinct, 0, 'distinct files count mismatch');
197+
assert.equal(res.equal, 5, 'equal files count mismatch');
198198
assert(res.totalFiles === 4);
199199
assert(res.totalDirs === 1);
200200
done();
201201
});
202202

203203
uncompressStream.on('entry', (header, stream, next) => {
204-
stream.on('end', next);
205-
206204
if (header.type === 'file') {
207-
stream.pipe(fs.createWriteStream(path.join(destDir, header.name)));
205+
pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name)))
206+
.then(next)
207+
.catch(done);
208208
} else { // directory
209209
fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => {
210210
if (err) return done(err);
211211
stream.resume();
212212
});
213+
stream.on('end', next);
213214
}
214215
});
215216
});
@@ -231,15 +232,16 @@ describe('test/zip/uncompress_stream.test.js', () => {
231232
});
232233

233234
uncompressStream.on('entry', (header, stream, next) => {
234-
stream.on('end', next);
235-
236235
if (header.type === 'file') {
237-
stream.pipe(fs.createWriteStream(path.join(destDir, header.name)));
236+
pipelinePromise(stream, fs.createWriteStream(path.join(destDir, header.name)))
237+
.then(next)
238+
.catch(done);
238239
} else { // directory
239240
fs.mkdir(path.join(destDir, header.name), { recursive: true }, err => {
240241
if (err) return done(err);
241242
stream.resume();
242243
});
244+
stream.on('end', next);
243245
}
244246
});
245247
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.