<commit_before>const pageIcon = require('./../src/index');
const fs = require("fs"); //Load the filesystem module
const chai = require('chai');
const expect = chai.expect;

const ICON_SIZE_THRESHOLD_KB = 0.5;

const SITE_URLS = [
    'https://www.facebook.com/'
];

function checkIfIsIcon(iconPath) {
    return new Promise(function (resolve, reject) {
        fs.stat(iconPath, function(error, fileInfo) {
            if (error) {
                reject(error);
                return;
            }

            const fileSizeKB = fileInfo.size / 1000;
            const isIcon = fileSizeKB > ICON_SIZE_THRESHOLD_KB;
            resolve(isIcon);
        });
    });
}

describe('Page Icon', function () {
    this.timeout(10000);

    it('Can download all icons', function(done) {

        const downloadTests = SITE_URLS.map(function (siteUrl) {
            return new Promise(function (resolve, reject) {
                pageIcon(siteUrl)
                    .then(checkIfIsIcon)
                    .then(function(isIcon) {
                        expect(isIcon).to.be.true;
                        resolve();
                    })
                    .catch(reject);
            });
        });

        Promise.all(downloadTests)
            .then(function() {
                done();
            })
            .catch(done);
    })
});
<commit_msg>Skip icon check if no icons are found<commit_after>const pageIcon = require('./../src/index');
const fs = require("fs"); //Load the filesystem module
const chai = require('chai');
const expect = chai.expect;

const ICON_SIZE_THRESHOLD_KB = 0.5;

const SITE_URLS = [
    'https://www.facebook.com/',
    'http://stackoverflow.com/questions/16301503/can-i-use-requirepath-join-to-safely-concatenate-urls'
];

function checkIfIsIcon(iconPath) {
    return new Promise((resolve, reject) => {
        fs.stat(iconPath, function(error, fileInfo) {
            if (error) {
                reject(error);
                return;
            }

            const fileSizeKB = fileInfo.size / 1000;
            const isIcon = fileSizeKB > ICON_SIZE_THRESHOLD_KB;
            resolve(isIcon);
        });
    });
}

describe('Page Icon', function () {
    this.timeout(10000);

    it('Can download all icons', function(done) {

        const downloadTests = SITE_URLS.map(function (siteUrl) {
            return new Promise(function (resolve, reject) {
                pageIcon(siteUrl)
                    .then(function(iconPath) {
                        if (!iconPath) {
                            throw `No icon found for url: ${siteUrl}`;
                        }

                        return checkIfIsIcon(iconPath);
                    })
                    .then(function(isIcon) {
                        expect(isIcon).to.be.true;
                        resolve();
                    })
                    .catch(reject);
            });
        });

        Promise.all(downloadTests)
            .then(function() {
                done();
            })
            .catch(done);
    })
});

{'fraction_non_alphanumeric': 0.1231623652401176, 'fraction_numerical': 0.009800718719372754, 'mean_word_length': 1.5453034081463008, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7005107', 'n_tokens_mistral': 901, 'n_tokens_neox': 830, 'n_words': 164}