Skip to content

Commit d59de3e

Browse files
authored
Update old test (#516)
* update test to work with mocha * update file name --------- Co-authored-by: 5saviahv <[email protected]>
1 parent 44b1006 commit d59de3e

File tree

2 files changed

+54
-50
lines changed

2 files changed

+54
-50
lines changed

test/issue_130/issue_130.test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"use strict";
2+
3+
const assert = require("assert");
4+
const fs = require("fs");
5+
const pth = require("path");
6+
const Zip = require("../../adm-zip");
7+
const rimraf = require("rimraf");
8+
9+
describe("ADM-ZIP - Issues", () => {
10+
const destination = pth.resolve("./test/xxx");
11+
const unzipped = pth.join(destination, "unzipped");
12+
13+
// clean up folder content
14+
afterEach((done) => rimraf(destination, done));
15+
16+
it("Issue 130 - Created zip's under Windows are corrupt", () => {
17+
// init the final zip file
18+
const writeZip = new Zip();
19+
20+
// file in root folder
21+
writeZip.addFile("root_file.txt", "root");
22+
23+
// add folder
24+
writeZip.addFile("sub/", Buffer.alloc(0));
25+
26+
// file in sub folder
27+
writeZip.addFile("sub/sub_file.txt", "sub");
28+
29+
// files from local folder
30+
writeZip.addLocalFolder(pth.resolve("./test/issue_130", "nested"), "nested");
31+
32+
// write to disk
33+
writeZip.writeZip(pth.join(destination, "test.zip"));
34+
35+
// read zip from disk
36+
const readZip = new Zip(pth.join(destination, "test.zip"));
37+
38+
// unpack everything
39+
readZip.extractAllTo(unzipped, true);
40+
41+
// assert the files
42+
const fileRoot = fs.readFileSync(pth.join(unzipped, "root_file.txt"), "utf8");
43+
assert(fileRoot === "root", "root file not correct");
44+
45+
const fileSub = fs.readFileSync(pth.join(unzipped, "sub/sub_file.txt"), "utf8");
46+
assert(fileSub === "sub", "sub file not correct");
47+
48+
const fileNested = fs.readFileSync(pth.join(unzipped, "nested/nested_file.txt"), "utf8");
49+
assert(fileNested === "nested", "nested file not correct");
50+
51+
const fileDeeper = fs.readFileSync(pth.join(unzipped, "nested/deeper/deeper_file.txt"), "utf8");
52+
assert(fileDeeper === "deeper", "deeper file not correct");
53+
});
54+
});

test/issue_130/test.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)