<commit_before>import { define } from '../../../src/index';

describe('lifecycle/defined', () => {
  it('should not already have the defined attribute on undefined elements', () => {
    expect(document.createElement('some-undefined-element').hasAttribute('defined')).to.equal(false);
  });

  it('should add the [defined] attribute when the element is upgraded', (done) => {
    const Elem = define('x-test', {});
    const elem = new Elem();

    document.body.appendChild(elem);

    setTimeout(() => {
      expect(elem.hasAttribute('defined')).to.equal(true);
      document.body.removeChild(elem);
      done();
    }, 1);
  });
});
<commit_msg>refactor: Use afterMutations. Add sanity check.<commit_after>import { define } from '../../../src/index';
import afterMutations from '../../lib/after-mutations';

describe('lifecycle/defined', () => {
  it('should not already have the defined attribute on undefined elements', () => {
    expect(document.createElement('some-undefined-element').hasAttribute('defined')).to.equal(false);
  });

  it('should add the [defined] attribute when the element is upgraded', (done) => {
    const Elem = define('x-test', {});
    const elem = new Elem();

    // Sanity check for non-native (native would throw).
    expect(elem.hasAttribute('defined')).to.equal(false);

    document.body.appendChild(elem);
    afterMutations(() => {
      expect(elem.hasAttribute('defined')).to.equal(true);
      document.body.removeChild(elem);
      done();
    }, 1);
  });
});

{'fraction_non_alphanumeric': 0.18663136995367308, 'fraction_numerical': 0.0013236267372600927, 'mean_word_length': 3.725, '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': '7125670', 'n_tokens_mistral': 434, 'n_tokens_neox': 429, 'n_words': 97}