<commit_before>import '../../../src/index';
import create from '../../lib/create';

describe('light/polyfill', function () {
  let host, light1, light2, root, slot, text;

  beforeEach(function () {
    slot = create('slot');
    host = create('div');
    root = host.attachShadow({ mode: 'closed' });

    root.appendChild(slot);

    light1 = create('light1');
    light2 = create('light2');
    text = document.createTextNode('text');

    host.appendChild(light1);
    host.appendChild(text);
    host.appendChild(light2);
  });

  it('assignedSlot', function () {
    expect(light1.assignedSlot).to.equal(slot);
  });

  it('parentElement', function () {
    expect(light1.parentElement).to.equal(host);
  });

  it('parentNode', function () {
    expect(light1.parentNode).to.equal(host);
  });

  it('nextSibling', function () {
    expect(light1.nextSibling).to.equal(text);
  });

  it('nextElementSibling', function () {
    expect(light1.nextElementSibling).to.equal(light2);
  });

  it('previousSibling', function () {
    expect(light2.previousSibling).to.equal(text);
  });

  it('previousElementSibling', function () {
    expect(light2.previousElementSibling).to.equal(light1);
  });

  describe('when removed', function () {
    let anotherHost, anotherNode, anotherRoot, anotherSlot;

    beforeEach(function () {
      anotherHost = create('div');
      anotherNode = create('div');
      anotherRoot = anotherHost.attachShadow({ mode: 'closed' });
      anotherSlot = create('slot');

      anotherRoot.appendChild(anotherSlot);
      host.removeChild(light1);
    });

    it('should null parentNode', function () {
      expect(light1.parentNode).to.equal(null);
    });

    it('should null assignedSlot', function () {
      expect(light1.assignedSlot).to.equal(null);
    });

    describe('and reparented to the same host', function () {
      beforeEach(function () {
        host.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(host);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(slot);
      });
    });

    describe('and reparented to a different host', function () {
      beforeEach(function () {
        anotherHost.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherHost);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(anotherSlot);
      });
    });

    describe('and reparented to a different node', function () {
      beforeEach(function () {
        anotherNode.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherNode);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(null);
      });
    });
  });

  describe('when directly reparented', function () {
    let anotherHost, anotherNode, anotherRoot, anotherSlot;

    beforeEach(function () {
      anotherHost = create('div');
      anotherNode = create('div');
      anotherRoot = anotherHost.attachShadow({ mode: 'closed' });
      anotherSlot = create('slot');

      anotherRoot.appendChild(anotherSlot);
    });

    describe('to the same host', function () {
      beforeEach(function () {
        host.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(host);
      });

      it('should reset assignedSlot', function () {
        expect(light1.assignedSlot).to.equal(slot);
      });
    });

    describe('to a different host', function () {
      beforeEach(function () {
        anotherHost.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherHost);
      });

      it('should reset assignedSlot', function () {
        expect(light1.assignedSlot).to.equal(anotherSlot);
      });
    });

    describe('to a different node', function () {
      beforeEach(function () {
        anotherNode.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherNode);
      });

      it('should reset assignedSlot', function () {
        expect(anotherNode.assignedSlot).to.equal(null);
      });
    });
  });

  describe('when text nodes are projected to a different spot than element nodes', function () {
    let host, light1, light2, root, namedSlot, text;

    beforeEach(function () {
      namedSlot = create('slot', {name: 'slottyMcSlotFace'});
      unamedSlot = create('slot');
      host = create('div');
      root = host.attachShadow({ mode: 'closed' });

      root.appendChild(namedSlot);
      root.appendChild(unamedSlot);

      light1 = create('div', {slot: 'slottyMcSlotFace'});
      light2 = create('div', {slot: 'slottyMcSlotFace'});
      text = document.createTextNode('text');

      host.appendChild(light1);
      host.appendChild(text);
      host.appendChild(light2);
    });

    it('should polyfill previousSibling of textNode', function () {<commit_msg>Changed name of slot in textNode tests<commit_after>import '../../../src/index';
import create from '../../lib/create';

describe('light/polyfill', function () {
  let host, light1, light2, root, slot, text;

  beforeEach(function () {
    slot = create('slot');
    host = create('div');
    root = host.attachShadow({ mode: 'closed' });

    root.appendChild(slot);

    light1 = create('light1');
    light2 = create('light2');
    text = document.createTextNode('text');

    host.appendChild(light1);
    host.appendChild(text);
    host.appendChild(light2);
  });

  it('assignedSlot', function () {
    expect(light1.assignedSlot).to.equal(slot);
  });

  it('parentElement', function () {
    expect(light1.parentElement).to.equal(host);
  });

  it('parentNode', function () {
    expect(light1.parentNode).to.equal(host);
  });

  it('nextSibling', function () {
    expect(light1.nextSibling).to.equal(text);
  });

  it('nextElementSibling', function () {
    expect(light1.nextElementSibling).to.equal(light2);
  });

  it('previousSibling', function () {
    expect(light2.previousSibling).to.equal(text);
  });

  it('previousElementSibling', function () {
    expect(light2.previousElementSibling).to.equal(light1);
  });

  describe('when removed', function () {
    let anotherHost, anotherNode, anotherRoot, anotherSlot;

    beforeEach(function () {
      anotherHost = create('div');
      anotherNode = create('div');
      anotherRoot = anotherHost.attachShadow({ mode: 'closed' });
      anotherSlot = create('slot');

      anotherRoot.appendChild(anotherSlot);
      host.removeChild(light1);
    });

    it('should null parentNode', function () {
      expect(light1.parentNode).to.equal(null);
    });

    it('should null assignedSlot', function () {
      expect(light1.assignedSlot).to.equal(null);
    });

    describe('and reparented to the same host', function () {
      beforeEach(function () {
        host.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(host);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(slot);
      });
    });

    describe('and reparented to a different host', function () {
      beforeEach(function () {
        anotherHost.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherHost);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(anotherSlot);
      });
    });

    describe('and reparented to a different node', function () {
      beforeEach(function () {
        anotherNode.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherNode);
      });

      it('should keep assignedSlot null', function () {
        expect(light1.assignedSlot).to.equal(null);
      });
    });
  });

  describe('when directly reparented', function () {
    let anotherHost, anotherNode, anotherRoot, anotherSlot;

    beforeEach(function () {
      anotherHost = create('div');
      anotherNode = create('div');
      anotherRoot = anotherHost.attachShadow({ mode: 'closed' });
      anotherSlot = create('slot');

      anotherRoot.appendChild(anotherSlot);
    });

    describe('to the same host', function () {
      beforeEach(function () {
        host.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(host);
      });

      it('should reset assignedSlot', function () {
        expect(light1.assignedSlot).to.equal(slot);
      });
    });

    describe('to a different host', function () {
      beforeEach(function () {
        anotherHost.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherHost);
      });

      it('should reset assignedSlot', function () {
        expect(light1.assignedSlot).to.equal(anotherSlot);
      });
    });

    describe('to a different node', function () {
      beforeEach(function () {
        anotherNode.appendChild(light1);
      });

      it('should reset parentNode', function () {
        expect(light1.parentNode).to.equal(anotherNode);
      });

      it('should reset assignedSlot', function () {
        expect(anotherNode.assignedSlot).to.equal(null);
      });
    });
  });

  describe('when text nodes are projected to a different spot than element nodes', function () {
    let host, light1, light2, root, namedSlot, text;

    beforeEach(function () {
      namedSlot = create('slot', {name: 'mySlot'});
      unamedSlot = create('slot');
      host = create('div');
      root = host.attachShadow({ mode: 'closed' });

      root.appendChild(namedSlot);
      root.appendChild(unamedSlot);

      light1 = create('div', {slot: 'mySlot'});
      light2 = create('div', {slot: 'mySlot'});
      text = document.createTextNode('text');

      host.appendChild(light1);
      host.appendChild(text);
      host.appendChild(light2);
    });

    it('should polyfill previousSibling of textNode', function () {
{'fraction_non_alphanumeric': 0.15832141154029566, 'fraction_numerical': 0.008202193609918931, 'mean_word_length': 3.0408477842003854, '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': '5420850', 'n_tokens_mistral': 3029, 'n_tokens_neox': 2962, 'n_words': 550}