Skip to content

Commit

Permalink
Update unit tests of listFiles function
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Jul 16, 2024
1 parent f821e02 commit 343eb45
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/import-export/tests/import/handlers/backup-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ describe( 'BackupHandlerFactory', () => {

describe( 'listFiles', () => {
const archiveFiles = [
'index.php',
'.hidden-file',
'wp-content/.hidden-file',
'wp-content/plugins/hello.php',
'wp-content/themes/twentytwentyfour/theme.json',
'wp-content/uploads/2024/07/image.png',
'__MACOSX/meta-file',
];
const expectedArchiveFiles = [
'index.php',
'wp-content/plugins/hello.php',
'wp-content/themes/twentytwentyfour/theme.json',
Expand All @@ -83,7 +92,7 @@ describe( 'BackupHandlerFactory', () => {
archiveFiles.forEach( ( path ) => onReadEntry?.( { path } as tar.ReadEntry ) );
} );

await expect( handler.listFiles( archiveInfo ) ).resolves.toEqual( archiveFiles );
await expect( handler.listFiles( archiveInfo ) ).resolves.toEqual( expectedArchiveFiles );
} );

it( 'should list files from a zip archive', async () => {
Expand All @@ -99,7 +108,7 @@ describe( 'BackupHandlerFactory', () => {
.mockReturnValue( archiveFiles.map( ( file ) => ( { entryName: file } ) ) ),
} );

await expect( handler.listFiles( archiveInfo ) ).resolves.toEqual( archiveFiles );
await expect( handler.listFiles( archiveInfo ) ).resolves.toEqual( expectedArchiveFiles );
} );

it( 'should list a single SQL file', async () => {
Expand Down

0 comments on commit 343eb45

Please sign in to comment.