<commit_before>var assert = require('assert'),
    RadioParser = require('./../lib/index');

describe('RadioParser', function () {
    it('Should create new instance', function () {
        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');
        assert(radio instanceof RadioParser, 'Should be instance of RadioParser');
    });

    it('Should properly get/set config', function () {
        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');

        assert.deepEqual(radio.getConfig(), {
            url: 'http://streaming.radionomy.com/HammerHeadRadio',
            keepListen: false,
            autoUpdate: true,
            errorInterval: 10 * 60,
            emptyInterval: 5 * 60,
            metadataInterval: 5
        }, 'Should properly set default config');

        radio.setConfig({
            url: 'http://another-link.com',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        });

        assert.deepEqual(radio.getConfig(), {
            url: 'http://another-link.com',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        }, 'Should properly update config');

        radio.setConfig({
            url: 'http://streaming.radionomy.com/HammerHeadRadio'
        });

        assert.deepEqual(radio.getConfig(), {
            url: 'http://streaming.radionomy.com/HammerHeadRadio',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        }, 'Should properly make particular update');

        assert.equal(radio.getConfig('keepListen'), true, 'Should properly get value from config by key');
    });

    it('Should properly emit metadata', function (done) {
        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');
        radio.on('metadata', function (metadata) {
            assert.equal(typeof metadata, 'object', 'Metadata should be object');
            assert.equal(typeof metadata.StreamTitle, 'string', 'StreamTitle should be string');
            done();
        });
    });
});<commit_msg>Add test case for ShoutCAST<commit_after>var assert = require('assert'),
    RadioParser = require('./../lib/index');

describe('RadioParser', function () {
    it('Should create new instance', function () {
        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');
        assert(radio instanceof RadioParser, 'Should be instance of RadioParser');
    });

    it('Should properly get/set config', function () {
        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');

        assert.deepEqual(radio.getConfig(), {
            url: 'http://streaming.radionomy.com/HammerHeadRadio',
            keepListen: false,
            autoUpdate: true,
            errorInterval: 10 * 60,
            emptyInterval: 5 * 60,
            metadataInterval: 5
        }, 'Should properly set default config');

        radio.setConfig({
            url: 'http://another-link.com',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        });

        assert.deepEqual(radio.getConfig(), {
            url: 'http://another-link.com',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        }, 'Should properly update config');

        radio.setConfig({
            url: 'http://streaming.radionomy.com/HammerHeadRadio'
        });

        assert.deepEqual(radio.getConfig(), {
            url: 'http://streaming.radionomy.com/HammerHeadRadio',
            keepListen: true,
            autoUpdate: false,
            errorInterval: 1000,
            emptyInterval: 900,
            metadataInterval: 800
        }, 'Should properly make particular update');

        assert.equal(radio.getConfig('keepListen'), true, 'Should properly get value from config by key');
    });

    it('Should properly emit metadata from Icecast', function (done) {
        this.timeout(5000);

        var radio = new RadioParser('http://streaming.radionomy.com/HammerHeadRadio');
        radio.on('metadata', function (metadata) {
            assert.equal(typeof metadata, 'object', 'Metadata should be object');
            assert.equal(typeof metadata.StreamTitle, 'string', 'StreamTitle should be string');
            console.log('Icecast -> ' + metadata.StreamTitle);
            done();
        });
    });

    it('Should properly emit metadata from ShoutCAST', function (done) {
        this.timeout(5000);

        var radio = new RadioParser('http://192.168.3.11/;?icy=http');
        radio.on('metadata', function (metadata) {
            assert.equal(typeof metadata, 'object', 'Metadata should be object');
            assert.equal(typeof metadata.StreamTitle, 'string', 'StreamTitle should be string');
            console.log('ShoutCAST -> ' + metadata.StreamTitle);
            done();
        });
    });
});
{'fraction_non_alphanumeric': 0.12481231231231231, 'fraction_numerical': 0.017454954954954954, 'mean_word_length': 2.216053108026554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '5060555', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1330, 'n_words': 326}