<commit_before>jest.dontMock('../HostUtil');

const HostUtil = require('../HostUtil');

describe('HostUtil', function () {

  describe('#stringToHostname', function () {

    it('should strip out invalid characters from the middle', function () {
      const result = HostUtil.stringToHostname('fd%gsf---gs7-f$gs--d7fddg-123');

      expect(result).toEqual('fdgsf---gs7-fgs--d7fddg-123');
    });

    it('should strip out invalid characters from the start', function () {
      const result = HostUtil.stringToHostname('-@4abc123');

      expect(result).toEqual('4abc123');
    });

    it('should strip out invalid characters from the end', function () {
      const result = HostUtil.stringToHostname('4abc123.');

      expect(result).toEqual('4abc123');
    });

    it('should strip invalid characters from the start and end', function () {
      const result = HostUtil.stringToHostname('##fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789-');

      expect(result).toEqual('fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789');
    });

    it('should return valid hostnames', function () {
      const result = HostUtil.stringToHostname('0-0');

      expect(result).toEqual('0-0');
    });

    it('should allow dashes within the hostname', function () {
      const result = HostUtil.stringToHostname('89fdgsf---gs7-fgs--d7fddg-123');

      expect(result).toEqual('89fdgsf---gs7-fgs--d7fddg-123');
    });

    it('should strip invalid characters and trim to 63 characters and remove invalid end characters', function () {
      const result = HostUtil.stringToHostname('fd%gsf---gs7-f$gs--d7fddg123456789012345678901234567890123456789-123');

      expect(result).toEqual('fdgsf---gs7-fgs--d7fddg1234567890123456789012345678901234567891');
    });

    it('should strip invalid start characters and trim to 63 characters and remove invalid end characters', function () {
      const result = HostUtil.stringToHostname('%%fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789---123');

      expect(result).toEqual('fdgsf---gs7-fgs--d7fddg1234567890123456789012345678901234567891');
    });

    it('should return valid strings', function () {
      const result = HostUtil.stringToHostname('a--------------------------------------------------------------b');

      expect(result).toEqual('a-------------------------------------------------------------b');
    });

    it('should lowercase the string', function () {
      const result = HostUtil.stringToHostname('XYZ');

      expect(result).toEqual('xyz');
    });

  });

});<commit_msg>Align tests with 80 char per line rule<commit_after>jest.dontMock('../HostUtil');

const HostUtil = require('../HostUtil');

describe('HostUtil', function () {

  describe('#stringToHostname', function () {

    it('should strip invalid chars', function () {
      const result = HostUtil.stringToHostname('fd%gsf---gs7-f$gs--d7fddg-123');

      expect(result).toEqual('fdgsf---gs7-fgs--d7fddg-123');
    });

    it('should strip invalid chars from the start', function () {
      const result = HostUtil.stringToHostname('-@4abc123');

      expect(result).toEqual('4abc123');
    });

    it('should strip invalid chars from the end', function () {
      const result = HostUtil.stringToHostname('4abc123.');

      expect(result).toEqual('4abc123');
    });

    it('should strip invalid chars from the start and end', function () {
      const result = HostUtil.stringToHostname(
        '##fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789-'
      );

      expect(result).toEqual(
        'fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789'
      );
    });

    it('should return valid hostnames', function () {
      const result = HostUtil.stringToHostname('0-0');

      expect(result).toEqual('0-0');
    });

    it('should allow dashes within the hostname', function () {
      const result = HostUtil.stringToHostname('89fdgsf---gs7-fgs--d7fddg-123');

      expect(result).toEqual('89fdgsf---gs7-fgs--d7fddg-123');
    });

    it('should strip invalid chars and trim string to 63 chars', function () {
      const result = HostUtil.stringToHostname(
        'fd%gsf---gs7-f$gs--d7fddg123456789012345678901234567890123456789-123'
      );

      expect(result).toEqual(
        'fdgsf---gs7-fgs--d7fddg1234567890123456789012345678901234567891'
      );
    });

    it('should strip invalid chars from start and trim string', function () {
      const result = HostUtil.stringToHostname(
        '%%fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789---123'
      );

      expect(result).toEqual(
        'fdgsf---gs7-fgs--d7fddg1234567890123456789012345678901234567891'
      );
    });

    it('should strip dashes from the end and trim string', function () {
      const result = HostUtil.stringToHostname(
        '%%fdgsf---gs7-fgs--d7fddg123456789012345678901234567890123456789---123'
      );

      expect(result).toEqual(
        'fdgsf---gs7-fgs--d7fddg1234567890123456789012345678901234567891'
      );
    });

    it('should not alter valid hostnames', function () {
      const result = HostUtil.stringToHostname(
        'a--------------------------------------------------------------b'
      );

      expect(result).toEqual(
        'a-------------------------------------------------------------b'
      );
    });

    it('should lowercase the string', function () {
      const result = HostUtil.stringToHostname('XYZ');

      expect(result).toEqual('xyz');
    });

  });

});
{'fraction_non_alphanumeric': 0.18683498647430116, 'fraction_numerical': 0.12443642921550947, 'mean_word_length': 2.7422402159244266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '528024', 'n_tokens_mistral': 2159, 'n_tokens_neox': 1675, 'n_words': 292}