<commit_before>import watch from '../../../src/api/watch';

describe('api/watch', function () {
  var parent;
  var child;
  var descendant;

  beforeEach(function () {
    parent = document.createElement('div');
    child = document.createElement('div');
    descendant = document.createElement('div');
  });

  it('should watch for added childNodes', function (done) {
    watch(parent, function (added, removed) {
      expect(added.length).to.equal(1);
      expect(removed.length).to.equal(0);
      done();
    });

    parent.appendChild(child);
  });

  it('should watch for removed childNodes', function (done) {
    parent.appendChild(child);

    watch(parent, function (added, removed) {
      expect(added.length).to.equal(0);
      expect(removed.length).to.equal(1);
      done();
    });

    child.remove();
  });

  it('should only watch immediate childNodes by default', function (done) {
    parent.appendChild(child);
    child.appendChild(descendant);

    watch(parent, function () {
      done('watcher triggered');
    });

    descendant.remove();
    setTimeout(done, 100);
  });

  it('should watch descendants if { subtree: true }', function (done) {
    parent.appendChild(child);
    child.appendChild(descendant);

    watch(parent, function (added, removed) {
      expect(added.length).to.equal(0);
      expect(removed.length).to.equal(1);
      done();
    }, {
      subtree: true
    });

    descendant.remove();
  });
});<commit_msg>tests: node.remove() isn't available in Internet Explorer (use removeChild).<commit_after>import watch from '../../../src/api/watch';

describe('api/watch', function () {
  var parent;
  var child;
  var descendant;

  beforeEach(function () {
    parent = document.createElement('div');
    child = document.createElement('div');
    descendant = document.createElement('div');
  });

  it('should watch for added childNodes', function (done) {
    watch(parent, function (added, removed) {
      expect(added.length).to.equal(1);
      expect(removed.length).to.equal(0);
      done();
    });

    parent.appendChild(child);
  });

  it('should watch for removed childNodes', function (done) {
    parent.appendChild(child);

    watch(parent, function (added, removed) {
      expect(added.length).to.equal(0);
      expect(removed.length).to.equal(1);
      done();
    });

    parent.removeChild(child);
  });

  it('should only watch immediate childNodes by default', function (done) {
    parent.appendChild(child);
    child.appendChild(descendant);

    watch(parent, function () {
      done('watcher triggered');
    });

    child.removeChild(descendant);
    setTimeout(done, 100);
  });

  it('should watch descendants if { subtree: true }', function (done) {
    parent.appendChild(child);
    child.appendChild(descendant);

    watch(parent, function (added, removed) {
      expect(added.length).to.equal(0);
      expect(removed.length).to.equal(1);
      done();
    }, {
      subtree: true
    });

    child.removeChild(descendant);
  });
});
{'fraction_non_alphanumeric': 0.1625, 'fraction_numerical': 0.0059210526315789476, 'mean_word_length': 3.2531468531468533, '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': '3270659', 'n_tokens_mistral': 910, 'n_tokens_neox': 883, 'n_words': 184}