Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Add a test for the 404 check
Browse files Browse the repository at this point in the history
Check was added in #4, this adds a test for it.

Also made it consistently return null, both when the downloaded file is not an icon and when a 404 is received.

Previously it was returning undefined for the latter.
  • Loading branch information
jiahaog authored Jan 16, 2021
1 parent 1a3d029 commit 9c062ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/modules/download/downloadIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function downloadIcon(iconUrl) {

return iconData.then(iconData => {
if (!iconData) {
return;
return null;
}

const fileDetails = fileType(iconData);
Expand Down
12 changes: 11 additions & 1 deletion test/downloadIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const expect = chai.expect;

const ICON_URL = 'https://web.whatsapp.com/favicon.ico';
const NOT_ICON_URL = 'http://jiahaog.github.io/nativefier-icons';
const STATUS_NOT_FOUND_URL = 'http://jiahaog.github.io/nativefier-icons/pleasegivemea404';

const ICON_PATH = path.join(__dirname, '..','out', 'test_icon.ico');

Expand All @@ -31,5 +32,14 @@ describe('Download Icons', function() {
done();
})
.catch(done);
})
});

it('Will return null if the icon ', function(done) {
downloadIcon(STATUS_NOT_FOUND_URL)
.then(icon => {
expect(icon).to.equal(null, 'Invalid icon should return null');
done();
})
.catch(done);
});
});

0 comments on commit 9c062ea

Please sign in to comment.