Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nika-begiashvili committed Jul 20, 2019
1 parent cc9ab5f commit b915497
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 112 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added test/files/archives/7z/bzip2.7z
Binary file not shown.
Binary file added test/files/archives/7z/lzma.7z
Binary file not shown.
Binary file added test/files/archives/7z/lzma2.7z
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file added test/files/archives/tar/test.tar.xz
Binary file not shown.
12 changes: 1 addition & 11 deletions test/files/test-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,11 @@
const file = e.currentTarget.files[0];
const archive = await Archive.open(file);
const files = await archive.getFilesArray();
//console.log(files);
fileObj = await files[0].file.extract();

objBefore = await archive.getFilesObject();
//console.log(f1);
objAfter = await archive.extractFiles();
//console.log( await archive.getFilesObject() );
//console.log( await archive.getFilesArray() );
objAfter = await fileChecksums(objAfter);
}catch(err){
console.error(err);
}finally{
window.fileObj = await getChecksum(fileObj);
window.obj = objAfter;
window.objBefore = objBefore;
window.obj = await getChecksum(fileObj);
finish();
}
});
Expand Down
36 changes: 36 additions & 0 deletions test/formats/7z.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-disable no-undef */
const {checksum} = require('../checksum');
const {navigate,inputFile,response,setup,cleanup} = require('../testutils');

let browser,page;

beforeAll(async () => {
let tmp = await setup();
browser = tmp.browser;
page = tmp.page;
});

describe("Extract 7Z files with various compressions", () => {
test("Extract 7Z with LZMA", async () => {
await navigate(page);
await inputFile('archives/7z/lzma.7z',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract 7Z with LZMA2", async () => {
await navigate(page);
await inputFile('archives/7z/lzma2.7z',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract 7Z with BZIP2", async () => {
await navigate(page);
await inputFile('archives/7z/bzip2.7z',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
});

afterAll(() => {
cleanup(browser);
});
30 changes: 30 additions & 0 deletions test/formats/rar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable no-undef */
const {checksum} = require('../checksum');
const {navigate,inputFile,response,setup,cleanup} = require('../testutils');

let browser,page;

beforeAll(async () => {
let tmp = await setup();
browser = tmp.browser;
page = tmp.page;
});

describe("Extract RAR files", () => {
test("Extract RAR v4", async () => {
await navigate(page);
await inputFile('archives/rar/test-v4.rar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract RAR v5", async () => {
await navigate(page);
await inputFile('archives/rar/test-v5.rar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
});

afterAll(() => {
cleanup(browser);
});
42 changes: 42 additions & 0 deletions test/formats/tar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable no-undef */
const {checksum} = require('../checksum');
const {navigate,inputFile,response,setup,cleanup} = require('../testutils');

let browser,page;

beforeAll(async () => {
let tmp = await setup();
browser = tmp.browser;
page = tmp.page;
});

describe("Extract TAR files with various compressions", () => {
test("Extract TAR without compression", async () => {
await navigate(page);
await inputFile('archives/tar/test.tar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract TAR BZIP2", async () => {
await navigate(page);
await inputFile('archives/tar/test.tar.bz2',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract TAR GZIP", async () => {
await navigate(page);
await inputFile('archives/tar/test.tar.gz',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("Extract TAR LZMA2", async () => {
await navigate(page);
await inputFile('archives/tar/test.tar.xz',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
});

afterAll(() => {
cleanup(browser);
});
4 changes: 2 additions & 2 deletions test/zip.test.js → test/formats/zip.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
const {checksum} = require('./checksum');
const {navigate,inputFile,response,setup,cleanup} = require('./testutils');
const {checksum} = require('../checksum');
const {navigate,inputFile,response,setup,cleanup} = require('../testutils');

let browser,page;

Expand Down
41 changes: 6 additions & 35 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,18 @@ beforeAll(async () => {
});

describe("extract various compression types", () => {
test("extract zip file", async () => {
await navigate(page);
await inputFile('archives/test.zip',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract 7z file", async () => {
await navigate(page);
await inputFile('archives/test.7z',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract tar file", async () => {
await navigate(page);
await inputFile('archives/test.tar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract tar.gz file", async () => {
await navigate(page);
await inputFile('archives/test.tar.gz',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract rar v4 file", async () => {
await navigate(page);
await inputFile('archives/test.rar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract rar v5 file", async () => {
await navigate(page);
await inputFile('archives/test-v5.rar',page);
const files = await response(page);
expect(files).toEqual(checksum);
}, 16000);
test("extract tar.bz2 file", async () => {
await navigate(page);
await inputFile('archives/test.tar.bz2',page);
const files = await response(page);
expect(files).toEqual(checksum);

test("extract single file from zip", async () => {
await navigate(page,'test-single.html');
await inputFile('archives/test.zip',page);
const file = await response(page);
expect(file).toEqual(checksum['.gitignore']);
}, 16000);
});

Expand Down
62 changes: 0 additions & 62 deletions test/singlefile.test.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/testutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module.exports = {
server.stop();
browser.close();
},
navigate: async function (page){
await page.goto(`http://127.0.0.1:${port}/test/files/index.html`);
navigate: async function (page, path = 'index.html') {
await page.goto(`http://127.0.0.1:${port}/test/files/${path}`);
},
inputFile: async function (file,page){
const fileInp = await page.$('#file');
Expand Down

0 comments on commit b915497

Please sign in to comment.