<commit_before>import { compileToFunctions } from 'vue-template-compiler';
import mount from '../../../src/mount';
import Wrapper from '../../../src/Wrapper';

// Vue components for testing purposes
import Form from '../../resources/components/form/Form.vue';
import ClickComponent from '../../resources/components/event-components/ClickComponent.vue';
import ClickToggleComponent from '../../resources/components/event-components/ClickToggleComponent.vue';
import KeydownComponent from '../../resources/components/event-components/KeydownComponent.vue';
import Submit from '../../resources/components/form/Submit.vue';
import Paragraph from '../../resources/components/paragraph/Paragraph.vue';
import ComputedProperties from '../../resources/components/data-components/ComputedProperties.vue';
import Parent from '../../resources/components/nested-components/Parent.vue';
import SecondChild from '../../resources/components/nested-components/SecondChild.vue';
import Transition from '../../resources/components/nested-components/Transition.vue';
import SlotParent from '../../resources/components/slots/SlotParent.vue';

describe('Wrapper', () => {
  describe('find', () => {
    it('returns an array of Wrappers of elements matching tag selector passed', () => {
      const compiled = compileToFunctions('<div><p></p><p></p></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('p');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(2);
    });

    it('returns an array of Wrapper of elements matching class selector passed', () => {
      const wrapper = mount(Form);
      const input = wrapper.find('.input-text')[0];
      expect(input).to.be.an.instanceOf(Wrapper);
      expect(input.element.className).to.equal('input-text');
    });

    it('returns an array of Wrapper of elements matching class selector passed if they are nested in a transition', () => {
      const wrapper = mount(Transition);
      const children = wrapper.find('.child');
      expect(children.length).to.equal(3);
    });

    it('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
      const wrapper = mount(SlotParent);
      const children = wrapper.find('.slot-footer-content');
      expect(children.length).to.equal(1);
    });

    it('returns an array of Wrappers of elements matching id selector passed', () => {
      const wrapper = mount(Form);
      const input = wrapper.find('#input-text')[0];

      expect(input).to.be.an.instanceOf(Wrapper);
      expect(input.element.className).to.equal('input-text');
    });

    it('returns an array of Wrappers of elements matching attribute selector passed', () => {
      const compiled = compileToFunctions('<div><a href="/"></a></div>');
      const wrapper = mount(compiled);
      expect(wrapper.find('[href="/"]').length).to.equal(1);
    });

    it('throws an error when passed an invalid DOM selector', () => {
      const compiled = compileToFunctions('<div><a href="/"></a></div>');
      const wrapper = mount(compiled);
      const message = 'wrapper.find() must be passed a valid CSS selector or a Vue constructor';
      expect(() => wrapper.find('[href=&6"/"]')).to.throw(Error, message);
    });

    it('returns an array of Wrappers of elements matching selector with descendant combinator passed', () => {
      const compiled = compileToFunctions('<div><ul><li>list</li>item<li></li></ul></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('div li');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(2);
    });

    it('does not return duplicate nodes', () => {
      const compiled = compileToFunctions('<div><div><div><p/></div></div></div></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('div p');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(1);
    });

    it('returns an array of Wrappers of elements matching selector with direct descendant combinator passed', () => {
      const compiled = compileToFunctions('<div><ul><ul></ul><ul/></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('div > ul');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(1);
    });
<commit_msg>improve find duplicate node test case<commit_after>import { compileToFunctions } from 'vue-template-compiler';
import mount from '../../../src/mount';
import Wrapper from '../../../src/Wrapper';

// Vue components for testing purposes
import Form from '../../resources/components/form/Form.vue';
import ClickComponent from '../../resources/components/event-components/ClickComponent.vue';
import ClickToggleComponent from '../../resources/components/event-components/ClickToggleComponent.vue';
import KeydownComponent from '../../resources/components/event-components/KeydownComponent.vue';
import Submit from '../../resources/components/form/Submit.vue';
import Paragraph from '../../resources/components/paragraph/Paragraph.vue';
import ComputedProperties from '../../resources/components/data-components/ComputedProperties.vue';
import Parent from '../../resources/components/nested-components/Parent.vue';
import SecondChild from '../../resources/components/nested-components/SecondChild.vue';
import Transition from '../../resources/components/nested-components/Transition.vue';
import SlotParent from '../../resources/components/slots/SlotParent.vue';

describe('Wrapper', () => {
  describe('find', () => {
    it('returns an array of Wrappers of elements matching tag selector passed', () => {
      const compiled = compileToFunctions('<div><p></p><p></p></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('p');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(2);
    });

    it('returns an array of Wrapper of elements matching class selector passed', () => {
      const wrapper = mount(Form);
      const input = wrapper.find('.input-text')[0];
      expect(input).to.be.an.instanceOf(Wrapper);
      expect(input.element.className).to.equal('input-text');
    });

    it('returns an array of Wrapper of elements matching class selector passed if they are nested in a transition', () => {
      const wrapper = mount(Transition);
      const children = wrapper.find('.child');
      expect(children.length).to.equal(3);
    });

    it('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
      const wrapper = mount(SlotParent);
      const children = wrapper.find('.slot-footer-content');
      expect(children.length).to.equal(1);
    });

    it('returns an array of Wrappers of elements matching id selector passed', () => {
      const wrapper = mount(Form);
      const input = wrapper.find('#input-text')[0];

      expect(input).to.be.an.instanceOf(Wrapper);
      expect(input.element.className).to.equal('input-text');
    });

    it('returns an array of Wrappers of elements matching attribute selector passed', () => {
      const compiled = compileToFunctions('<div><a href="/"></a></div>');
      const wrapper = mount(compiled);
      expect(wrapper.find('[href="/"]').length).to.equal(1);
    });

    it('throws an error when passed an invalid DOM selector', () => {
      const compiled = compileToFunctions('<div><a href="/"></a></div>');
      const wrapper = mount(compiled);
      const message = 'wrapper.find() must be passed a valid CSS selector or a Vue constructor';
      expect(() => wrapper.find('[href=&6"/"]')).to.throw(Error, message);
    });

    it('returns an array of Wrappers of elements matching selector with descendant combinator passed', () => {
      const compiled = compileToFunctions('<div><ul><li>list</li>item<li></li></ul></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('div li');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(2);
    });

    it('does not return duplicate nodes', () => {
      const compiled = compileToFunctions('<div><div><div><p/><p/></div></div></div></div>');
      const wrapper = mount(compiled);console.log(wrapper);
      const divs = wrapper.find('div p');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(2);
    });

    it('returns an array of Wrappers of elements matching selector with direct descendant combinator passed', () => {
      const compiled = compileToFunctions('<div><ul><ul></ul><ul/></div>');
      const wrapper = mount(compiled);
      const divs = wrapper.find('div > ul');
      expect(divs[0]).to.be.an.instanceOf(Wrapper);
      expect(divs.length).to.equal(1);
    });

{'fraction_non_alphanumeric': 0.1717103026181571, 'fraction_numerical': 0.003173523744758019, 'mean_word_length': 3.634453781512605, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 104, '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': '2242940', 'n_tokens_mistral': 2387, 'n_tokens_neox': 2378, 'n_words': 591}