Skip to content

Commit

Permalink
Update old test (#516)
Browse files Browse the repository at this point in the history
* update test to work with mocha
* update file name

---------

Co-authored-by: 5saviahv <5saviahv@users.noreply.github.com>
  • Loading branch information
5saviahv and 5saviahv authored Jun 26, 2024
1 parent 44b1006 commit d59de3e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 50 deletions.
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.

0 comments on commit d59de3e

Please sign in to comment.