<commit_before>import * as IncrementalDOM from 'incremental-dom';
import { define, vdom } from '../../../src/index';

function testBasicApi (name) {
  describe(name, () => {
    it('should be a function', () => expect(vdom[name]).to.be.a('function'));
    it('should not be the same one as in Incremental DOM', () => expect(vdom[name]).not.to.equal(IncrementalDOM[name]));
  });
}

describe('IncrementalDOM', function () {
  testBasicApi('attr');
  testBasicApi('elementClose');
  testBasicApi('elementOpen');
  testBasicApi('elementOpenEnd');
  testBasicApi('elementOpenStart');
  testBasicApi('elementVoid');
  testBasicApi('text');

  describe('function tag names', () => {
    let fixture;
    beforeEach(() => fixture = document.createElement('div'));

    function patchIt(desc, func) {
      it(desc, () => IncrementalDOM.patch(fixture, func));
    }

    describe.only('passing a component constructor', () => {
      const Elem = define('x-test', {});

      patchIt('elementOpen, elementClose', () => {
        vdom.elementOpen(Elem);
        expect(vdom.elementClose(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });

      patchIt('elementOpenStart, elementOpenEnd, elementClose', () => {
        vdom.elementOpenStart(Elem);
        vdom.elementOpenEnd(Elem);
        expect(vdom.elementClose(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });
      
      patchIt('elementVoid', () => {
        expect(vdom.elementVoid(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });
    });

    describe('passing a function helper', () => {
      function patchAssert(elem, { checkChildren = true } = {}) {
        expect(fixture.firstChild).to.equal(elem);
        expect(fixture.innerHTML).to.equal(`<div id="test">${ checkChildren ? '<span>test</span>' : ''}</div>`);
      }

      function renderChildren() {
        vdom.elementOpen('span');
        vdom.text('test');
        vdom.elementClose('span');<commit_msg>test(vdom): Remove .only()<commit_after>import * as IncrementalDOM from 'incremental-dom';
import { define, vdom } from '../../../src/index';

function testBasicApi (name) {
  describe(name, () => {
    it('should be a function', () => expect(vdom[name]).to.be.a('function'));
    it('should not be the same one as in Incremental DOM', () => expect(vdom[name]).not.to.equal(IncrementalDOM[name]));
  });
}

describe('IncrementalDOM', function () {
  testBasicApi('attr');
  testBasicApi('elementClose');
  testBasicApi('elementOpen');
  testBasicApi('elementOpenEnd');
  testBasicApi('elementOpenStart');
  testBasicApi('elementVoid');
  testBasicApi('text');

  describe('function tag names', () => {
    let fixture;
    beforeEach(() => fixture = document.createElement('div'));

    function patchIt(desc, func) {
      it(desc, () => IncrementalDOM.patch(fixture, func));
    }

    describe('passing a component constructor', () => {
      const Elem = define('x-test', {});

      patchIt('elementOpen, elementClose', () => {
        vdom.elementOpen(Elem);
        expect(vdom.elementClose(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });

      patchIt('elementOpenStart, elementOpenEnd, elementClose', () => {
        vdom.elementOpenStart(Elem);
        vdom.elementOpenEnd(Elem);
        expect(vdom.elementClose(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });
      
      patchIt('elementVoid', () => {
        expect(vdom.elementVoid(Elem).outerHTML).to.equal('<x-test defined></x-test>');
      });
    });

    describe('passing a function helper', () => {
      function patchAssert(elem, { checkChildren = true } = {}) {
        expect(fixture.firstChild).to.equal(elem);
        expect(fixture.innerHTML).to.equal(`<div id="test">${ checkChildren ? '<span>test</span>' : ''}</div>`);
      }

      function renderChildren() {
        vdom.elementOpen('span');
        vdom.text('test');
        vdom.elementClose('span');
{'fraction_non_alphanumeric': 0.19234668018246326, 'fraction_numerical': 0.0, 'mean_word_length': 3.5735805330243338, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 45, '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': '4020577', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1192, 'n_words': 189}