@@ -6,72 +6,44 @@ import {
66 readZipEntries ,
77} from "../../../src/common/unzip" ;
88
9- const zipWithSingleFilePath = resolve (
10- __dirname ,
11- "../../vscode-tests/no-workspace/data/archive-filesystem-provider-test/single_file.zip" ,
12- ) ;
13- const zipWithFolderPath = resolve (
14- __dirname ,
15- "../../vscode-tests/no-workspace/data/archive-filesystem-provider-test/zip_with_folder.zip" ,
16- ) ;
9+ const zipPath = resolve ( __dirname , "../data/unzip/test-zip.zip" ) ;
1710
1811describe ( "openZip" , ( ) => {
1912 it ( "can open a zip file" , async ( ) => {
20- const zipFile = await openZip ( zipWithFolderPath , {
13+ const zipFile = await openZip ( zipPath , {
2114 lazyEntries : false ,
2215 } ) ;
2316
24- expect ( zipFile . entryCount ) . toEqual ( 8 ) ;
17+ expect ( zipFile . entryCount ) . toEqual ( 11 ) ;
2518 } ) ;
2619} ) ;
2720
2821describe ( "readZipEntries" , ( ) => {
29- it ( "can read the entries when there is a single file " , async ( ) => {
30- const zipFile = await openZip ( zipWithSingleFilePath , {
22+ it ( "can read the entries when there are multiple directories " , async ( ) => {
23+ const zipFile = await openZip ( zipPath , {
3124 lazyEntries : true ,
3225 } ) ;
3326 const entries = await readZipEntries ( zipFile ) ;
3427
3528 expect ( entries . map ( ( entry ) => entry . fileName ) . sort ( ) ) . toEqual ( [
36- "src_archive/" ,
37- "src_archive/aFileName.txt" ,
38- ] ) ;
39- } ) ;
40-
41- it ( "can read the entries when there are multiple folders" , async ( ) => {
42- const zipFile = await openZip ( zipWithFolderPath , {
43- lazyEntries : true ,
44- } ) ;
45- const entries = await readZipEntries ( zipFile ) ;
46-
47- expect ( entries . map ( ( entry ) => entry . fileName ) . sort ( ) ) . toEqual ( [
48- "__MACOSX/._folder1" ,
49- "__MACOSX/folder1/._textFile.txt" ,
50- "__MACOSX/folder1/._textFile2.txt" ,
51- "folder1/" ,
52- "folder1/folder2/" ,
53- "folder1/folder2/textFile3.txt" ,
54- "folder1/textFile.txt" ,
55- "folder1/textFile2.txt" ,
29+ "directory/" ,
30+ "directory/file.txt" ,
31+ "directory/file2.txt" ,
32+ "directory2/" ,
33+ "directory2/file.txt" ,
34+ "empty-directory/" ,
35+ "tools/" ,
36+ "tools/osx64/" ,
37+ "tools/osx64/java-aarch64/" ,
38+ "tools/osx64/java-aarch64/bin/" ,
39+ "tools/osx64/java-aarch64/bin/java" ,
5640 ] ) ;
5741 } ) ;
5842} ) ;
5943
6044describe ( "excludeDirectories" , ( ) => {
61- it ( "excludes directories when there is a single file" , async ( ) => {
62- const zipFile = await openZip ( zipWithSingleFilePath , {
63- lazyEntries : true ,
64- } ) ;
65- const entries = await readZipEntries ( zipFile ) ;
66- const entriesWithoutDirectories = excludeDirectories ( entries ) ;
67-
68- expect (
69- entriesWithoutDirectories . map ( ( entry ) => entry . fileName ) . sort ( ) ,
70- ) . toEqual ( [ "src_archive/aFileName.txt" ] ) ;
71- } ) ;
72-
73- it ( "excludes directories when there are multiple folders" , async ( ) => {
74- const zipFile = await openZip ( zipWithFolderPath , {
45+ it ( "excludes directories" , async ( ) => {
46+ const zipFile = await openZip ( zipPath , {
7547 lazyEntries : true ,
7648 } ) ;
7749 const entries = await readZipEntries ( zipFile ) ;
@@ -80,34 +52,32 @@ describe("excludeDirectories", () => {
8052 expect (
8153 entriesWithoutDirectories . map ( ( entry ) => entry . fileName ) . sort ( ) ,
8254 ) . toEqual ( [
83- "__MACOSX/._folder1" ,
84- "__MACOSX/folder1/._textFile.txt" ,
85- "__MACOSX/folder1/._textFile2.txt" ,
86- "folder1/folder2/textFile3.txt" ,
87- "folder1/textFile.txt" ,
88- "folder1/textFile2.txt" ,
55+ "directory/file.txt" ,
56+ "directory/file2.txt" ,
57+ "directory2/file.txt" ,
58+ "tools/osx64/java-aarch64/bin/java" ,
8959 ] ) ;
9060 } ) ;
9161} ) ;
9262
9363describe ( "openZipBuffer" , ( ) => {
9464 it ( "can read an entry in the zip file" , async ( ) => {
95- const zipFile = await openZip ( zipWithFolderPath , {
65+ const zipFile = await openZip ( zipPath , {
9666 lazyEntries : true ,
9767 autoClose : false ,
9868 } ) ;
9969 const entries = await readZipEntries ( zipFile ) ;
10070
10171 const entry = entries . find (
102- ( entry ) => entry . fileName === "folder1/textFile .txt" ,
72+ ( entry ) => entry . fileName === "directory/file .txt" ,
10373 ) ;
10474 expect ( entry ) . toBeDefined ( ) ;
10575 if ( ! entry ) {
10676 return ;
10777 }
10878
10979 const buffer = await openZipBuffer ( zipFile , entry ) ;
110- expect ( buffer ) . toHaveLength ( 12 ) ;
111- expect ( buffer . toString ( "utf8" ) ) . toEqual ( "I am a text \n" ) ;
80+ expect ( buffer ) . toHaveLength ( 13 ) ;
81+ expect ( buffer . toString ( "utf8" ) ) . toEqual ( "I am a file\n \n" ) ;
11282 } ) ;
11383} ) ;
0 commit comments