<commit_before>/*
Todos:
0. Confirm working cross-browser (all browsers); remove IE8 processing instruction hack?
0. When CDATA XML-check added, add check for CDATA section in XML
0. Fix bug with IE 10 (but not IE 8) when testing $on events (race condition)
*/

import * as xmlTesting from './xmlTesting.js';

describe('Jamilih - jml', function () {
  beforeEach(() => {
    while (body.firstChild) {
      body.firstChild.remove();
    }
    let jmlTestContent = $('#jmlTestContent');
    if (!jmlTestContent) {
      jmlTestContent = document.createElement('div');
      jmlTestContent.id = 'jmlTestContent';
      body.append(jmlTestContent);
    }
    jmlTestContent.innerHTML = `
      <div style="display:none;" id="DOMChildrenMustBeInArray">test1</div>
      <div style="display:none;" id="anotherElementToAddToParent">test2</div>
      <div style="display:none;" id="yetAnotherSiblingToAddToParent">test3</div>
    `;
  });
  it('Single element with no children', () => {
    xmlTesting.matchesXMLString(
      jml('input'),
      '<input xmlns="http://www.w3.org/1999/xhtml" />',
      'Single element argument element'
    );
    xmlTesting.matchesXMLString(
      jml('input', null),
      '<input xmlns="http://www.w3.org/1999/xhtml" />',
      'Single element argument with `null` at end'
    );

    xmlTesting.matchesXMLString(
      jml('input', {type: 'password', id: 'my_pass'}),
      '<input xmlns="http://www.w3.org/1999/xhtml" type="password" id="my_pass" />',
      'Single element with two attributes'
    );
  });

  it('DOM attributes', function () {
    xmlTesting.matchesXMLString(
      jml('div', {
        innerHTML: '<span>Test</span>'
      }),
      '<div xmlns="http://www.w3.org/1999/xhtml"><span>Test</span></div>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        htmlFor: 'someId'
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml" for="someId"></label>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        for: 'someId'
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml" for="someId"></label>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        for: null
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml"></label>'
    );
    let input = jml('input', {
      checked: true
    });
    expect(input.checked).to.be.true;
    input = jml('input', {
      readonly: true
    });
    expect(input.readOnly).to.be.true;
    input = jml('input', {
      readOnly: true
    });
    expect(input.readOnly).to.be.true;
    const option = jml('option', {
      selected: true
    });
    expect(option.selected).to.be.true;
    const custom = jml('custom', {<commit_msg>- Testing (coverage): nullish className<commit_after>/*
Todos:
0. Confirm working cross-browser (all browsers); remove IE8 processing instruction hack?
0. When CDATA XML-check added, add check for CDATA section in XML
0. Fix bug with IE 10 (but not IE 8) when testing $on events (race condition)
*/

import * as xmlTesting from './xmlTesting.js';

describe('Jamilih - jml', function () {
  beforeEach(() => {
    while (body.firstChild) {
      body.firstChild.remove();
    }
    let jmlTestContent = $('#jmlTestContent');
    if (!jmlTestContent) {
      jmlTestContent = document.createElement('div');
      jmlTestContent.id = 'jmlTestContent';
      body.append(jmlTestContent);
    }
    jmlTestContent.innerHTML = `
      <div style="display:none;" id="DOMChildrenMustBeInArray">test1</div>
      <div style="display:none;" id="anotherElementToAddToParent">test2</div>
      <div style="display:none;" id="yetAnotherSiblingToAddToParent">test3</div>
    `;
  });
  it('Single element with no children', () => {
    xmlTesting.matchesXMLString(
      jml('input'),
      '<input xmlns="http://www.w3.org/1999/xhtml" />',
      'Single element argument element'
    );
    xmlTesting.matchesXMLString(
      jml('input', null),
      '<input xmlns="http://www.w3.org/1999/xhtml" />',
      'Single element argument with `null` at end'
    );

    xmlTesting.matchesXMLString(
      jml('input', {type: 'password', id: '<PASSWORD>'}),
      '<input xmlns="http://www.w3.org/1999/xhtml" type="password" id="<PASSWORD>" />',
      'Single element with two attributes'
    );
  });

  it('DOM attributes', function () {
    xmlTesting.matchesXMLString(
      jml('div', {
        innerHTML: '<span>Test</span>'
      }),
      '<div xmlns="http://www.w3.org/1999/xhtml"><span>Test</span></div>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        htmlFor: 'someId'
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml" for="someId"></label>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        for: 'someId'
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml" for="someId"></label>'
    );
    xmlTesting.matchesXMLString(
      jml('label', {
        for: null
      }),
      '<label xmlns="http://www.w3.org/1999/xhtml"></label>'
    );
    xmlTesting.matchesXMLString(
      jml('div', {
        className: 'aClass'
      }),
      '<div xmlns="http://www.w3.org/1999/xhtml" class="aClass"></div>'
    );
    xmlTesting.matchesXMLString(
      jml('div', {
        class: 'aClass'
      }),
      '<div xmlns="http://www.w3.org/1999/xhtml" class="aClass"></div>'
    );
    xmlTesting.matchesXMLString(
      jml('div', {
        class: null
      }),
      '<div xmlns="http://www.w3.org/1999/xhtml"></div>'
    );
    let input = jml('input', {
      checked: true
    });
    expect(input.checked).to.be.true;
    input = jml('input', {
      readonly: true
    });
    expect(input.readOnly).to.be.true;
    input = jml('input', {
      readOnly: true
    });
    expect(input.readOnly).to.be.true;
    const option = jml('option', {
      selected: true
    });
    expect(option.selected).to.be.true;
    const custom = jml('custom', {
{'fraction_non_alphanumeric': 0.17653061224489797, 'fraction_numerical': 0.017857142857142856, 'mean_word_length': 2.8114063512637717, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 17, 'xml': 38}, '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': '1306836', 'n_tokens_mistral': 2009, 'n_tokens_neox': 1915, 'n_words': 358}