forked from EvanOxfeld/node-unzip
-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathbroken.js
41 lines (34 loc) · 986 Bytes
/
broken.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const test = require('tap').test;
const fs = require('fs');
const path = require('path');
const temp = require('temp');
const unzip = require('../');
test("Parse a broken zipfile", function (t) {
const archive = path.join(__dirname, '../testData/compressed-standard/broken.zip');
fs.createReadStream(archive)
.pipe(unzip.Parse())
.on('entry', function(entry) {
return entry.autodrain();
})
.promise()
.catch(function(e) {
t.same(e.message, 'FILE_ENDED');
t.end();
});
});
test("extract a broken", function (t) {
const archive = path.join(__dirname, '../testData/compressed-standard/broken.zip');
temp.mkdir('node-unzip-', function (err, dirPath) {
if (err) {
throw err;
}
const unzipExtractor = unzip.Extract({ path: dirPath });
fs.createReadStream(archive)
.pipe(unzipExtractor)
.promise()
.catch(function(e) {
t.same(e.message, 'FILE_ENDED');
t.end();
});
});
});