From b915497bb21eafd644f4e059732fe6cd92c336ea Mon Sep 17 00:00:00 2001 From: Nika Date: Sat, 20 Jul 2019 10:21:06 +0400 Subject: [PATCH] Add more tests --- test/{zip => archive_content}/test/.gitignore | 0 test/{zip => archive_content}/test/README.md | 0 .../test/addon/addon.py | 0 .../test/addon/addon.xml | 0 test/files/archives/7z/bzip2.7z | Bin 0 -> 2358 bytes test/files/archives/7z/lzma.7z | Bin 0 -> 2140 bytes test/files/archives/7z/lzma2.7z | Bin 0 -> 2142 bytes .../archives/{test.rar => rar/test-v4.rar} | Bin test/files/archives/{ => rar}/test-v5.rar | Bin test/files/archives/{ => tar}/test.tar | Bin test/files/archives/{ => tar}/test.tar.bz2 | Bin test/files/archives/{ => tar}/test.tar.gz | Bin 2136 -> 2132 bytes test/files/archives/tar/test.tar.xz | Bin 0 -> 2160 bytes test/files/test-single.html | 12 +--- test/formats/7z.test.js | 36 ++++++++++ test/formats/rar.test.js | 30 +++++++++ test/formats/tar.test.js | 42 ++++++++++++ test/{ => formats}/zip.test.js | 4 +- test/main.test.js | 41 ++---------- test/singlefile.test.js | 62 ------------------ test/testutils.js | 4 +- 21 files changed, 119 insertions(+), 112 deletions(-) rename test/{zip => archive_content}/test/.gitignore (100%) rename test/{zip => archive_content}/test/README.md (100%) rename test/{zip => archive_content}/test/addon/addon.py (100%) rename test/{zip => archive_content}/test/addon/addon.xml (100%) create mode 100644 test/files/archives/7z/bzip2.7z create mode 100644 test/files/archives/7z/lzma.7z create mode 100644 test/files/archives/7z/lzma2.7z rename test/files/archives/{test.rar => rar/test-v4.rar} (100%) rename test/files/archives/{ => rar}/test-v5.rar (100%) rename test/files/archives/{ => tar}/test.tar (100%) rename test/files/archives/{ => tar}/test.tar.bz2 (100%) rename test/files/archives/{ => tar}/test.tar.gz (98%) create mode 100644 test/files/archives/tar/test.tar.xz create mode 100644 test/formats/7z.test.js create mode 100644 test/formats/rar.test.js create mode 100644 test/formats/tar.test.js rename test/{ => formats}/zip.test.js (91%) delete mode 100644 test/singlefile.test.js diff --git a/test/zip/test/.gitignore b/test/archive_content/test/.gitignore similarity index 100% rename from test/zip/test/.gitignore rename to test/archive_content/test/.gitignore diff --git a/test/zip/test/README.md b/test/archive_content/test/README.md similarity index 100% rename from test/zip/test/README.md rename to test/archive_content/test/README.md diff --git a/test/zip/test/addon/addon.py b/test/archive_content/test/addon/addon.py similarity index 100% rename from test/zip/test/addon/addon.py rename to test/archive_content/test/addon/addon.py diff --git a/test/zip/test/addon/addon.xml b/test/archive_content/test/addon/addon.xml similarity index 100% rename from test/zip/test/addon/addon.xml rename to test/archive_content/test/addon/addon.xml diff --git a/test/files/archives/7z/bzip2.7z b/test/files/archives/7z/bzip2.7z new file mode 100644 index 0000000000000000000000000000000000000000..cdb0445d70258a5652b313eb67ccb03d576bd929 GIT binary patch literal 2358 zcmV-63CZ?1dc3bE8~_BP%Z9k~2mk;80000Z000000002H@g2WHT4*^jL0KkKS)Ebf z&j10{e~Cm?00dkA`}e=^-mbs@|LOn;fB@hL9521u6$;(EZ2@(T*aWu91qK-@lOarK znmtCso{&9HNB{w#&}aZOdW<*#0000002lxO000K2Od@K427mwn000000f0z~Vod@b zlS!%S9-4ZS(^J$B5^W&J9#G9po|8wZgMa`400001fB*mh07#I4ASRhIG6>O=5|2$A zM8HJTL7>pks3eT%pzeUPM|L|96U5l)(E|nyYBxOHlnN@M1)fuC7}9C1nFFs&>V1Bj8DkIu1fc@`%Z2D!y^P}e*^cU%V<3qpCJrAxy9J7>nxe~_ zYRM~LtENQn#~Rh;rb>y9rNpJ%Lgo)c0q~X%W(f(O7+fo|o=B0C zGEr&2N;ZSQv~7{$n_H1g_-7)uo>?(gWv{TfP-4=A$+fQ`ghpx9{j(NRYU_{wDq5bP?9mPHOUQu(pP zv#{npMdt1g1LzYNi@V`NP|fEN=zg20^gnjPlh7!op}NU)&2;3%krtZOlQFWF;E!-G zo?o(NEp0NhiXb16N=zW@HcT zWhGpAn7U1GY_oCCvM+(;K8!7$&QtgW;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Y^fJ%l1|K~_mXcrlR3M4}x@lh9^6j~j9exgwk>NKUBmXMg|zfinlL57mak z+Ser0{<4>P&agz3%|Hotxs|!j@73d{As-G@W?~gHR((^S^ahqm;J;}Hkt3QDvS-tg zK+*@~m$MdM6^TwMsX^vkv|>d~I}0h%Dqx?YQapnwUiQMCg=TrV90gVLZi9+T4CIy! zkE(6J;NBDV8!ug8a{?7Z&zSno3PH&^77yUGqWK0r-PYr0sYDx3ivSk}h*tp#fSdpa c3jqKDBLe{e1zi9T000bt`U(O17lyU~0FQn({Qv*} literal 0 HcmV?d00001 diff --git a/test/files/archives/7z/lzma.7z b/test/files/archives/7z/lzma.7z new file mode 100644 index 0000000000000000000000000000000000000000..47b9bc95deaef0e77037f3687953d01c15608417 GIT binary patch literal 2140 zcmV-i2&4Bmdc3bE8~_B7=}yY-pw-u(|27gc$sPy{~{m4K?$mELuro zW3zy|)zPV1x^CY}`Dbhc|Chv~4)r9{XUldwudE$RuI?PqSiwcv0GHbP%#1@8gHPUl zbw~t+)W#A15BQBecc%fW9hK~{f-C9x5KMl&o7W7FsDOaG!n8S1h1+kFd+$*%&<%e` ztuElirj=Lq!JO%Cj$}jyhzni9kQcZ|C_uBd{DpH51Zbai68Ji<4`Bu1yWR=NIGAxm|kNYa;$l!0LA;aGmU@Z zN7JuQR3?=Z7A3!&`2$A}tUzXjP_jxE?&kA-?rsvnmfdyxWf*R~tf|&pD2@_26gpZn z%n=w;RjX7Oq6ZA*4@0#*Mr*3RhNWB6(pB>z z2O`ghZi=uE0?Bq@%QIMKfy%BmTLt(!xyFtc{K*9d7GRlxP1jU~9>pUDn7}dem9jhZ z`E*0?HtOTsxJa6>-1m>&M(m%rC&0J>K_&%`#Bdk@x>5p9o>XLH*Y@3tk|ehCExQrw zwILP8ojhJT{Fk#YA<<3rKuE*Z_jPsYkqi)D;*h|eaDn8cq62|(VXt>fvpYIYzy~cM zREnyuF`KByTug)Ih%IC@JgbR7!X@O_Ao}Lg_C}3|Gv1odY~q>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eOrA!`bzgTLztt@95DJc2AWHnY;FE7Y2uT0SSPi00#>J00AQd0RaVF S01yBG41o#?0n6&9@c;ltZzEFx literal 0 HcmV?d00001 diff --git a/test/files/archives/7z/lzma2.7z b/test/files/archives/7z/lzma2.7z new file mode 100644 index 0000000000000000000000000000000000000000..739024689692bb66085c5a19a8a4b4e704199029 GIT binary patch literal 2142 zcmV-k2%+~kdc3bE8~_BP?#@vg2mk;80000Z000000002SVTC{7732qZT>ue?1gJUN zMVvy-Irb^Zsw0}|mC*Y#dLW#|kVI)OBhybYQkm(byqj!jrXjGo>9T|v{C~Z#fIj-%9ysYyG%*#e!QF443DUQfV;x9IZ%b$Z28i>L|l! z5;+t)S~JWL?Ehu`~pSLH#xBx*W1&+jU7y!Cb0#BY)WMtR&-HMVV zw(~8!5$d%e6~>)BUON1jvo9ghP4qxW!`An8b?K1|5MSbuz@Bh{4#YuPri)}4 z45O5jf!_S~G60G=00iZ2Nd_#?Nj#>i2oqxSYUf_Ax-zp2GT8S(HXLt zZA0Js-vka0J5X2QpGcNftQwHLMT=iJxw=ge$Ers(w>PB!!?R1FA5_8L1AeEBFb^JZ zy$L<=LQ3nWGX;?4_})H-yh_)_5w}tYw>k34iundodWfgmgwEEvA4zFIOfa!lmIaNaY7VHkrI0Fsf0`7LqE>89_fQtozstYhda^Dj<~PRDlzBC zmNsByi!`JbjVo^E|D8s!Y(iMJ)Gm~_(#NNJd*rKRKfR5C2a+5!7gfGPdGmsct1GEz zw>+(S{;)``i%=doH_d}zeUhgw$3L#twu^ASl#no0M~H730rt|z7#hP8Xl|-4B#B24 zBzxscqBb?5n3Uowd?vD*pabX6J1r}zG5v+AefvZ{u>yU1;Y>u-%O5RQ8N5&Twz|~r z@ttsw)^i=d4-{q9RZ$igia6Ae91cbTqWKEyj!v*#P`pWLQ}?2IwwI$8fAjTu3ls&+ z6IzF;?X4?t|2eHdV?jNZpJ$qo;1ZU5jO=P7A;r=$T8E~C?)Kzh*|Ev?S`PlI>P^pZ z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_Qvz*{GkHPrb+N6 zc@Kc>iZzgE^(g=ffQ*&sGr@AGUWd&(gMd`L9~P;BHm!h;`pbmP8~wCOg;@hayp0&O zryljgpe#!VZ1g3M(H-B&((&b!+lFP=kBReW-hR7fN*4oW1M&9?nD6w4 z_u{>Wi5@;LYg*BN@spHF@1DV1voE-$)+39hI_PJUp-V`b+Q0k?#t6C&k_GfXG2(D< zMd-DH?z3?qSlNn&&SK*IW|ZXaDt$-Zejx=tvqfC)dv;!2`ByHW2!GqNccIc+IbCuEIcKr}VW zlAXF0ob&U`Y&Isl92e20Z>>`A6x-x7!s89&1)$XjGbf4WvV_i)9PAgnBZkj?<7?^xC{8TbB@n#77mr~;hC|8l{ zja}IzR_*MYO4&QY_P+nA%1l3xoj%N!8xF$RQ82?hqR(_#DTWwo(Ztl}E47yE0V zGxhRr2R2Py4XGQf?a4M)l9NcZS>n|p-NqDny;F6Lx&Mp5!WDcA*<(AJm53H165Ac) z*qc)a1+zTV>GZ(JkU7I1Y#T9Gu$|hpyCt=YX>v%IUd~$AdJ^*Ly=2G4chw;~(KX9x zSAUT~?PB(JpYz=oK%u7}Q8L%Nh#V3=53|V)vt6=d_VWvc z@nxk&a(M>PGu`&mEZ7&-q_Ybz#8wYQSIUj5Fujr=3k0B;N(Nn%RNN*rl1&Bp z&YD@*VnO%+pk}g?L)VkyTzN{lZjLg%2J|7(HtvfxCl7*ydk2eKFbf&hUn;H} { + 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); +}); \ No newline at end of file diff --git a/test/formats/rar.test.js b/test/formats/rar.test.js new file mode 100644 index 0000000..80c16a4 --- /dev/null +++ b/test/formats/rar.test.js @@ -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); +}); \ No newline at end of file diff --git a/test/formats/tar.test.js b/test/formats/tar.test.js new file mode 100644 index 0000000..561bd6f --- /dev/null +++ b/test/formats/tar.test.js @@ -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); +}); \ No newline at end of file diff --git a/test/zip.test.js b/test/formats/zip.test.js similarity index 91% rename from test/zip.test.js rename to test/formats/zip.test.js index 95bdce6..d06cee8 100644 --- a/test/zip.test.js +++ b/test/formats/zip.test.js @@ -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; diff --git a/test/main.test.js b/test/main.test.js index f73a05b..5eaec80 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -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); }); diff --git a/test/singlefile.test.js b/test/singlefile.test.js deleted file mode 100644 index bd2aa1d..0000000 --- a/test/singlefile.test.js +++ /dev/null @@ -1,62 +0,0 @@ -const {checksum} = require('./checksum'); -const puppeteer = require('puppeteer'); - -const StaticServer = require('static-server'); -const port = 8788; -const server = new StaticServer({ - rootPath: '.', - port: port, - cors: '*', -}); - -const startServer = () => new Promise((resolve,reject) => { - server.start( () => { - console.log('Server listening to', port); - resolve(); - }); -}); - -let page; -let browser; -const width = 800; -const height = 600; - -async function navigate(){ - await page.goto(`http://127.0.0.1:${port}/test/files/test-single.html`); -} -async function inputFile(file){ - const fileInp = await page.$('#file'); - fileInp.uploadFile('test/files/'+file); -} -async function response(){ - await page.waitForSelector('#done'); - return { - filesObj: await page.evaluate(`window.obj`), - file: await page.evaluate(`window.fileObj`) - }; -} - -beforeAll(async () => { - browser = await puppeteer.launch(); - page = await browser.newPage(); - await page.setViewport({ width, height }); - await startServer(); - page.on('console', msg => { - for (let i = 0; i < msg.args().length; ++i) console.log(`${i}: ${msg.args()[i]}`); - }); -}); - -describe("test file listing", () => { - test("extract single file from zip", async () => { - await navigate(); - await inputFile('archives/test.zip'); - const { filesObj, file } = await response(); - expect(filesObj).toEqual(checksum); - expect(file).toEqual(checksum['.gitignore']); - }, 16000); -}); - -afterAll(() => { - server.stop(); - browser.close(); -}); \ No newline at end of file diff --git a/test/testutils.js b/test/testutils.js index 10f7ba2..d70f5ec 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -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');