<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

'use strict';

const utils = require('../lib/utils.js');
const testRunner = require('sdk/test');

exports.testGetHostURL = (assert) => {
    let url = 'https://www.allizom.org/en-US/firefox/new/';
    assert.equal(utils.getHostURL(url), 'https://www.allizom.org');

    url = 'http://127.0.0.8000/en-US/';
    assert.equal(utils.getHostURL(url), 'http://127.0.0.8000');

    url = 'about:home';
    assert.equal(utils.getHostURL(url), null);
};

exports.testAddToCommaString = (assert) => {
    let commaString = '';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        'https://www-demo1.allizom.org',
        'Single items should not have a trailing comma');

    commaString = 'https://www.allizom.org';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        'https://www.allizom.org,https://www-demo1.allizom.org',
        'Additional items should get added');

    commaString = 'https://www.allizom.org,https://www-demo1.allizom.org';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        commaString, 'Duplicate items should not get added');

    commaString = 'https://www.allizom.org,https://www-demo1.allizom.org';
    assert.equal(utils.addToCommaString(null, commaString), commaString,
        'Falsey items should not get added');
};

testRunner.run(exports);
<commit_msg>Fix typo in test description<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

'use strict';

const utils = require('../lib/utils.js');
const testRunner = require('sdk/test');

exports.testGetHostURL = (assert) => {
    let url = 'https://www.allizom.org/en-US/firefox/new/';
    assert.equal(utils.getHostURL(url), 'https://www.allizom.org');

    url = 'http://127.0.0.8000/en-US/';
    assert.equal(utils.getHostURL(url), 'http://127.0.0.8000');

    url = 'about:home';
    assert.equal(utils.getHostURL(url), null);
};

exports.testAddToCommaString = (assert) => {
    let commaString = '';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        'https://www-demo1.allizom.org',
        'Single items should not have a trailing comma');

    commaString = 'https://www.allizom.org';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        'https://www.allizom.org,https://www-demo1.allizom.org',
        'Additional items should get added');

    commaString = 'https://www.allizom.org,https://www-demo1.allizom.org';
    assert.equal(utils.addToCommaString('https://www-demo1.allizom.org', commaString),
        commaString, 'Duplicate items should not get added');

    commaString = 'https://www.allizom.org,https://www-demo1.allizom.org';
    assert.equal(utils.addToCommaString(null, commaString), commaString,
        'Falsy values should not get added');
};

testRunner.run(exports);

{'fraction_non_alphanumeric': 0.1685496183206107, 'fraction_numerical': 0.017709923664122138, 'mean_word_length': 3.556328233657858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 26, 'lorem ipsum': 0, 'www.': 26, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '307202', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1104, 'n_words': 216}