Skip to content

Commit

Permalink
update(lib): add additional check for downloaded file
Browse files Browse the repository at this point in the history
  • Loading branch information
elaichenkov committed Sep 14, 2022
1 parent 49c2df0 commit a3633c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cypress/e2e/verify-download.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ describe('verify download functionality', () => {

cy.verifyDownload('large-file-100MB', { contains: true });
});

it('downloads file with extension and contains option', () => {
cy.exec(`rm -rf ${Cypress.config('downloadsFolder')}`);
cy.get('[data-cy="large"]').click();

cy.verifyDownload('large-file-100MB.zip', { contains: true });
});
});
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ const isFileExist = (path) => existsSync(path);
const findFiles = ({ path, fileName }) => {
if (!existsSync(path)) return null;

return readdirSync(path).filter((file) => file.includes(fileName));
return readdirSync(path).filter((file) => file.includes(fileName) && isDownloaded(file));
};

const isDownloaded = (file) => !file.endsWith('.crdownload');

module.exports = {
isFileExist,
findFiles,
Expand Down

0 comments on commit a3633c8

Please sign in to comment.