<commit_before>import * as TextFormatting from '@/helpers/TextFormatting';

describe('TextFormatting.js', function() {
    it('should return valid channel links', function() {
        let tests = [
            ['#channel', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>'],
            ['#channel;', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>;'],
            ['#chan;nel', '<a class="u-link kiwi-channel" data-channel-name="#chan;nel">#chan;nel</a>'],
            ['#channel.', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>.'],
            ['#chan;el;', '<a class="u-link kiwi-channel" data-channel-name="#chan;el">#chan;el</a>;'],
            ['#chan[n]el,', '<a class="u-link kiwi-channel" data-channel-name="#chan[n]el">#chan[n]el</a>,'],
            ['@#channel:', '@<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>:'],
            ['@&channel,', '@<a class="u-link kiwi-channel" data-channel-name="&amp;channel">&amp;channel</a>,'],
        ];

        tests.forEach((c) => {
            let formatted = TextFormatting.linkifyChannels(c[0]);
            expect(formatted).to.equal(c[1]);
        });
    });

    it('should return valid url links', function() {
        let tests = [
            ['http://example.com', 'http://example.com'],
            ['http://127.0.0.1', 'http://127.0.0.1'],
            ['http://example.com:8080', 'http://example.com:8080'],
            ['http://127.0.0.1:8001', 'http://127.0.0.1:8001'],
            ['http://example.com/test.html?test=foo#bar', 'http://example.com/test.html?test=foo#bar'],
            ['http://127.0.0.1/test.html?test=foo#bar', 'http://127.0.0.1/test.html?test=foo#bar'],
            ['www.example.com', 'http://www.example.com'],
            ['https://www.example.com', 'https://www.example.com'],
            ['https://127.0.0.1/test.html?test=foo#bar', 'https://127.0.0.1/test.html?test=foo#bar'],
            ['http://2001:0000:1234:0000:0000:C1C0:ABCD:0876/', 'http://2001:0000:1234:0000:0000:C1C0:ABCD:0876/'],
            ['http://[2001:fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:de8:7648:6e8]:100/', 'http://[2001:fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:de8:7648:6e8]:100/'],
            ['ldap://[2001:db8::7]/c=GB?objectClass?one', 'ldap://[2001:db8::7]/c=GB?objectClass?one'],
        ];

        tests.forEach((c) => {
            let linkified = TextFormatting.linkifyUrls(c[0]);
            expect(linkified.urls[0]).to.equal(c[1]);
        });
    });<commit_msg>Tidy TextFormatting.spec.js<commit_after>import * as TextFormatting from '@/helpers/TextFormatting';

describe('TextFormatting.js', function() {
    it('should return valid channel links', function() {
        let tests = [
            ['#channel', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>'],
            ['#channel;', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>;'],
            ['#chan;nel', '<a class="u-link kiwi-channel" data-channel-name="#chan;nel">#chan;nel</a>'],
            ['#channel.', '<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>.'],
            ['#chan;el;', '<a class="u-link kiwi-channel" data-channel-name="#chan;el">#chan;el</a>;'],
            ['#chan[n]el,', '<a class="u-link kiwi-channel" data-channel-name="#chan[n]el">#chan[n]el</a>,'],
            ['@#channel:', '@<a class="u-link kiwi-channel" data-channel-name="#channel">#channel</a>:'],
            ['@&channel,', '@<a class="u-link kiwi-channel" data-channel-name="&amp;channel">&amp;channel</a>,'],
        ];

        tests.forEach((c) => {
            let formatted = TextFormatting.linkifyChannels(c[0]);
            expect(formatted).to.equal(c[1]);
        });
    });

    it('should return valid url links', function() {
        let tests = [
            ['www.example.com', 'http://www.example.com'],
            ['http://example.com'],
            ['http://127.0.0.1'],
            ['http://example.com:8080'],
            ['http://127.0.0.1:8001'],
            ['http://example.com/test.html?test=foo#bar'],
            ['http://127.0.0.1/test.html?test=foo#bar'],
            ['https://www.example.com'],
            ['https://127.0.0.1/test.html?test=foo#bar'],
            ['http://2001:0000:1234:0000:0000:C1C0:ABCD:0876/'],
            ['http://[2001:fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:de8:7648:6e8]:100/'],
            ['ldap://[2001:db8::7]/c=GB?objectClass?one'],
        ];

        tests.forEach((c) => {
            let linkified = TextFormatting.linkifyUrls(c[0]);
            let compare = c.length === 2 ? c[1] : c[0];
            expect(linkified.urls[0]).to.equal(compare);
        });
    });
{'fraction_non_alphanumeric': 0.24436486201811672, 'fraction_numerical': 0.06382978723404255, 'mean_word_length': 2.7802547770700636, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 6, 'lorem ipsum': 0, 'www.': 7, 'xml': 0}, 'pii_count': 12, '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': '6704922', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1683, 'n_words': 190}