<commit_before>const ParserHtml = require('parser/model/ParserHtml');
const ParserCss = require('parser/model/ParserCss');
const DomComponents = require('dom_components');

module.exports = {
  run() {

    describe('ParserHtml', () => {
      var obj;

      beforeEach(() => {
        var dom = new DomComponents();
        obj = new ParserHtml({
          textTags: ['br', 'b', 'i', 'u'],
          pStylePrefix: 'gjs-',
        });
        obj.compTypes = dom.componentTypes;
      });

      afterEach(() => {
        obj = null;
      });

      it('Simple div node', () => {
        var str = '<div></div>';
        var result = { tagName: 'div'};
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Simple article node', () => {
        var str = '<article></article>';
        var result = { tagName: 'article'};
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Node with attributes', () => {
        var str = '<div id="test1" class="test2 test3" data-one="test4" strange="test5"></div>';
        var result = {
          tagName: 'div',
          classes: ['test2', 'test3'],
          attributes: {
            'data-one': 'test4',
            id: 'test1',
            'strange': 'test5'
          }
        };
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Parse style string to object', () => {
        var str = 'color:black; width:100px; test:value;';
        var result = {
          color: 'black',
          width: '100px',
          test: 'value',
        };
        expect(obj.parseStyle(str)).toEqual(result)
      });

      it('Parse class string to array', () => {
        var str = 'test1 test2    test3 test-4';
        var result = ['test1', 'test2', 'test3', 'test-4'];
        expect(obj.parseClass(str)).toEqual(result)
      });

      it('Parse class string to array with special classes', () => {
        var str = 'test1 test2    test3 test-4 gjs-test';
        var result = ['test1', 'test2', 'test3', 'test-4'];
        expect(obj.parseClass(str)).toEqual(result)
      });

      it('Style attribute is isolated', () => {
        var str = '<div id="test1" style="color:black; width:100px; test:value;"></div>';
        var result = {<commit_msg>test style parsing for attributes containing colon<commit_after>const ParserHtml = require('parser/model/ParserHtml');
const ParserCss = require('parser/model/ParserCss');
const DomComponents = require('dom_components');

module.exports = {
  run() {

    describe('ParserHtml', () => {
      var obj;

      beforeEach(() => {
        var dom = new DomComponents();
        obj = new ParserHtml({
          textTags: ['br', 'b', 'i', 'u'],
          pStylePrefix: 'gjs-',
        });
        obj.compTypes = dom.componentTypes;
      });

      afterEach(() => {
        obj = null;
      });

      it('Simple div node', () => {
        var str = '<div></div>';
        var result = { tagName: 'div'};
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Simple article node', () => {
        var str = '<article></article>';
        var result = { tagName: 'article'};
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Node with attributes', () => {
        var str = '<div id="test1" class="test2 test3" data-one="test4" strange="test5"></div>';
        var result = {
          tagName: 'div',
          classes: ['test2', 'test3'],
          attributes: {
            'data-one': 'test4',
            id: 'test1',
            'strange': 'test5'
          }
        };
        expect(obj.parse(str).html).toEqual(result)
      });

      it('Parse style string to object', () => {
        var str = 'color:black; width:100px; test:value;';
        var result = {
          color: 'black',
          width: '100px',
          test: 'value',
        };
        expect(obj.parseStyle(str)).toEqual(result)
      });

      it('Parse style string with values containing colon to object', () => {
        var str = 'background-image:url("https://some-website.ex"); test:value;';
        var result = {
          'background-image': 'url("https://some-website.ex")',
          'test': 'value',
        };
        expect(obj.parseStyle(str)).toEqual(result)
      });


      it('Parse class string to array', () => {
        var str = 'test1 test2    test3 test-4';
        var result = ['test1', 'test2', 'test3', 'test-4'];
        expect(obj.parseClass(str)).toEqual(result)
      });

      it('Parse class string to array with special classes', () => {
        var str = 'test1 test2    test3 test-4 gjs-test';
        var result = ['test1', 'test2', 'test3', 'test-4'];
        expect(obj.parseClass(str)).toEqual(result)
      });

      it('Style attribute is isolated', () => {
        var str = '<div id="test1" style="color:black; width:100px; test:value;"></div>';
        var result = {
{'fraction_non_alphanumeric': 0.1801470588235294, 'fraction_numerical': 0.014705882352941176, 'mean_word_length': 2.113159567705022, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 40, 'https://': 2, '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': '2217626', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1467, 'n_words': 334}