Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update old test #516

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions test/issue_130/issue_130.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"use strict";

const assert = require("assert");
const fs = require("fs");
const pth = require("path");
const Zip = require("../../adm-zip");
const rimraf = require("rimraf");

describe("ADM-ZIP - Issues", () => {
const destination = pth.resolve("./test/xxx");
const unzipped = pth.join(destination, "unzipped");

// clean up folder content
afterEach((done) => rimraf(destination, done));

it("Issue 130 - Created zip's under Windows are corrupt", () => {
// init the final zip file
const writeZip = new Zip();

// file in root folder
writeZip.addFile("root_file.txt", "root");

// add folder
writeZip.addFile("sub/", Buffer.alloc(0));

// file in sub folder
writeZip.addFile("sub/sub_file.txt", "sub");

// files from local folder
writeZip.addLocalFolder(pth.resolve("./test/issue_130", "nested"), "nested");

// write to disk
writeZip.writeZip(pth.join(destination, "test.zip"));

// read zip from disk
const readZip = new Zip(pth.join(destination, "test.zip"));

// unpack everything
readZip.extractAllTo(unzipped, true);

// assert the files
const fileRoot = fs.readFileSync(pth.join(unzipped, "root_file.txt"), "utf8");
assert(fileRoot === "root", "root file not correct");

const fileSub = fs.readFileSync(pth.join(unzipped, "sub/sub_file.txt"), "utf8");
assert(fileSub === "sub", "sub file not correct");

const fileNested = fs.readFileSync(pth.join(unzipped, "nested/nested_file.txt"), "utf8");
assert(fileNested === "nested", "nested file not correct");

const fileDeeper = fs.readFileSync(pth.join(unzipped, "nested/deeper/deeper_file.txt"), "utf8");
assert(fileDeeper === "deeper", "deeper file not correct");
});
});
50 changes: 0 additions & 50 deletions test/issue_130/test.js

This file was deleted.