<commit_before>/* eslint-env jasmine, mocha */

import create from '../../lib/create';

describe('DocumentFragment', () => {
  it('should report the correct parent node for nested nodes', () => {
    const frag = document.createDocumentFragment();
    const elem = create();
    frag.appendChild(elem);
    expect(elem.parentNode).to.equal(frag);
  });

  it('should remove child elements when appending a document fragment', () => {
    const div1 = create();
    const div2 = create();

    const frag = document.createDocumentFragment();
    frag.appendChild(div1);
    frag.appendChild(div2);

    const elem = create();
    elem.appendChild(frag);
    expect(frag.childNodes.length).to.equal(0);
  });

  it('should correctly report the host node of children that are reparented', () => {
    const frag = document.createDocumentFragment();
    const ch1 = create();
    const ch2 = create();
    const ch3 = create();
    const target = create();

    frag.appendChild(ch1);
    frag.appendChild(ch2);
    frag.appendChild(ch3);

    target.appendChild(frag);

    // Make sure that lengths are in sync between the source and target.
    expect(frag.children.length).to.equal(0);
    expect(target.children.length).to.equal(3);

    // We ensure we're reporting the correct parent.
    expect(ch1.parentNode).to.equal(target);
    expect(ch2.parentNode).to.equal(target);
    expect(ch3.parentNode).to.equal(target);

    // It should also not error when removed. This is how the original problem
    // presented itself. Theoretically this is ensured by checking the
    // parentNode above, but it's probably good to have a sanity check here to
    // ensure it's cleaned up.
    ch1.parentNode.removeChild(ch1);
    ch2.parentNode.removeChild(ch2);
    ch3.parentNode.removeChild(ch3);
    expect(ch1.parentNode).to.equal(null);
    expect(ch2.parentNode).to.equal(null);
    expect(ch3.parentNode).to.equal(null);
  });
});<commit_msg>refactor: Refactor tests to work in IE.<commit_after>/* eslint-env jasmine, mocha */

import create from '../../lib/create';

describe('DocumentFragment', () => {
  it('should report the correct parent node for nested nodes', () => {
    const frag = document.createDocumentFragment();
    const elem = create();
    frag.appendChild(elem);
    expect(elem.parentNode).to.equal(frag);
  });

  it('should remove child elements when appending a document fragment', () => {
    const div1 = create();
    const div2 = create();

    const frag = document.createDocumentFragment();
    frag.appendChild(div1);
    frag.appendChild(div2);

    const elem = create();
    elem.appendChild(frag);
    expect(frag.childNodes.length).to.equal(0);
  });

  it('should correctly report the host node of children that are reparented', () => {
    const frag = document.createDocumentFragment();
    const ch1 = create();
    const ch2 = create();
    const ch3 = create();
    const target = create();

    frag.appendChild(ch1);
    frag.appendChild(ch2);
    frag.appendChild(ch3);

    target.appendChild(frag);

    // Make sure that lengths are in sync between the source and target.
    expect(frag.childNodes.length).to.equal(0);
    expect(target.childNodes.length).to.equal(3);

    // We ensure we're reporting the correct parent.
    expect(ch1.parentNode).to.equal(target);
    expect(ch2.parentNode).to.equal(target);
    expect(ch3.parentNode).to.equal(target);

    // It should also not error when removed. This is how the original problem
    // presented itself. Theoretically this is ensured by checking the
    // parentNode above, but it's probably good to have a sanity check here to
    // ensure it's cleaned up.
    ch1.parentNode.removeChild(ch1);
    ch2.parentNode.removeChild(ch2);
    ch3.parentNode.removeChild(ch3);
    expect(ch1.parentNode).to.equal(null);
    expect(ch2.parentNode).to.equal(null);
    expect(ch3.parentNode).to.equal(null);
  });
});
{'fraction_non_alphanumeric': 0.1357142857142857, 'fraction_numerical': 0.012755102040816327, 'mean_word_length': 3.4658314350797266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3083899', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1131, 'n_words': 306}