<commit_before>/* eslint-env mocha */

import expect from 'expect';

import { Component, define, h } from 'src';

import afterMutations from '../lib/after-mutations';
import fixture from '../lib/fixture';

describe('withRender', () => {
  describe('renderCallback()', () => {
    it('should be called', done => {
      const Elem = define(class extends Component {
        renderCallback () {
          return h('div');
        }
      });

      const elem = new Elem();
      fixture(elem);
      afterMutations(done);
    });

    it('should get called before descendants are initialised', done => {
      const called = [];
      const Elem1 = define(class extends Component {
        constructor () {
          super();
          called.push('elem1');
        }
      });
      const Elem2 = define(class extends Component {
        constructor () {
          super();
          called.push('elem2');
        }
      });

      fixture(`<${Elem1.is}><${Elem2.is}></${Elem2.is}></${Elem1.is}>`);
      afterMutations(
        () => expect(called[0]).toEqual('elem1'),
        () => expect(called[1]).toEqual('elem2'),
        done
      );
    });

    it('should pass in the element as the only argument', done => {
      const Elem = define(class extends Component {
        static props = {
          test: null
        }
        renderCallback (elem) {
          const { test } = elem.props;
          expect(this).toBe(elem);
          return h('div', null, test);
        }
      });

      const elem = new Elem();
      elem.test = 'testing';
      fixture(elem);
      afterMutations(
        () => expect(elem.shadowRoot.firstChild.textContent).toBe('testing'),<commit_msg>refactor: Removed unnecessary code from test.<commit_after>/* eslint-env mocha */

import expect from 'expect';

import { Component, define, h } from 'src';

import afterMutations from '../lib/after-mutations';
import fixture from '../lib/fixture';

describe('withRender', () => {
  describe('renderCallback()', () => {
    it('should be called', done => {
      const Elem = define(class extends Component {
        renderCallback () {
          return h('div');
        }
      });

      const elem = new Elem();
      fixture(elem);
      afterMutations(done);
    });

    it('should get called before descendants are initialised', done => {
      const called = [];
      const Elem1 = define(class extends Component {
        constructor () {
          super();
          called.push('elem1');
        }
      });
      const Elem2 = define(class extends Component {
        constructor () {
          super();
          called.push('elem2');
        }
      });

      fixture(`<${Elem1.is}><${Elem2.is}></${Elem2.is}></${Elem1.is}>`);
      afterMutations(
        () => expect(called[0]).toEqual('elem1'),
        () => expect(called[1]).toEqual('elem2'),
        done
      );
    });

    it('should pass in the element as the only argument', done => {
      const Elem = define(class extends Component {
        renderCallback (elem) {
          expect(this).toBe(elem);
          return h('div', null, 'called');
        }
      });

      const elem = new Elem();
      fixture(elem);
      afterMutations(
        () => expect(elem.shadowRoot.firstChild.textContent).toBe('called'),
{'fraction_non_alphanumeric': 0.16073059360730593, 'fraction_numerical': 0.0073059360730593605, 'mean_word_length': 2.181026137463698, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '6620388', 'n_tokens_mistral': 922, 'n_tokens_neox': 919, 'n_words': 215}