<commit_before>'use strict';

import helpers from '../lib/helpers';
import skate from '../../src/skate';

describe('ignoring', function () {
  it('should ignore a flagged element if defined after it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    helpers.fixture(`<${tag.safe} data-skate-ignore></${tag.safe}>`);
    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    skate.init(document.getElementsByTagName(tag.safe));
    expect(called).to.equal(0);
  });

  it('should ignore a flagged element if defined before it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    helpers.fixture(`<${tag.safe} data-skate-ignore></${tag.safe}>`);
    skate.init(document.getElementsByTagName(tag.safe));
    expect(called).to.equal(0);
  })

  it('should ignore children of a flagged element if defined after it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    helpers.fixture(`<div data-skate-ignore><${tag.safe}></${tag.safe}></div>`);
    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    skate.init(helpers.fixture());
    expect(called).to.equal(0);
  });

  it('should ignore children of a flagged element if defined before it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    helpers.fixture(`<div data-skate-ignore><${tag.safe}></${tag.safe}></div>`);
    skate.init(helpers.fixture());
    expect(called).to.equal(0);
  });

  it('should ignore descendants of a flagged element if defined after it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    helpers.fixture(`<div data-skate-ignore><div><${tag.safe}></${tag.safe}></div></div>`);
    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    skate.init(helpers.fixture());
    expect(called).to.equal(0);
  });

  it('should ignore descendants of a flagged element if defined before it is inserted', function () {
    var called = 0;
    var tag = helpers.safeTagName();

    skate(tag.safe, {
      created: function () {
        ++called;
      }
    });
    helpers.fixture(`<div data-skate-ignore><div><${tag.safe}></${tag.safe}></div></div>`);
    skate.init(helpers.fixture());
    expect(called).to.equal(0);
  });
});<commit_msg>Add assertions to make sure that attached doesn't get fired either. Refactor tests.<commit_after>'use strict';

import helpers from '../lib/helpers';
import skate from '../../src/skate';

describe('ignoring', function () {
  var created;
  var attached;
  var tag;
  var definition = {
    created: function () {
      ++created;
    },
    attached: function () {
      ++attached;
    }
  };

  function assertCalls () {
    expect(created).to.equal(0);
    expect(attached).to.equal(0);
  }

  beforeEach(function () {
    created = 0;
    attached = 0;
    tag = helpers.safeTagName();
  });

  it('should ignore a flagged element if defined after it is inserted', function () {
    helpers.fixture(`<${tag.safe} data-skate-ignore></${tag.safe}>`);
    skate(tag.safe, definition);
    skate.init(document.getElementsByTagName(tag.safe));
    assertCalls();
  });

  it('should ignore a flagged element if defined before it is inserted', function () {
    skate(tag.safe, definition);
    helpers.fixture(`<${tag.safe} data-skate-ignore></${tag.safe}>`);
    skate.init(document.getElementsByTagName(tag.safe));
    assertCalls();
  })

  it('should ignore children of a flagged element if defined after it is inserted', function () {
    helpers.fixture(`<div data-skate-ignore><${tag.safe}></${tag.safe}></div>`);
    skate(tag.safe, definition);
    skate.init(helpers.fixture());
    assertCalls();
  });

  it('should ignore children of a flagged element if defined before it is inserted', function () {
    skate(tag.safe, definition);
    helpers.fixture(`<div data-skate-ignore><${tag.safe}></${tag.safe}></div>`);
    skate.init(helpers.fixture());
    assertCalls();
  });

  it('should ignore descendants of a flagged element if defined after it is inserted', function () {
    helpers.fixture(`<div data-skate-ignore><div><${tag.safe}></${tag.safe}></div></div>`);
    skate(tag.safe, definition);
    skate.init(helpers.fixture());
    assertCalls();
  });

  it('should ignore descendants of a flagged element if defined before it is inserted', function () {
    skate(tag.safe, definition);
    helpers.fixture(`<div data-skate-ignore><div><${tag.safe}></${tag.safe}></div></div>`);
    skate.init(helpers.fixture());
    assertCalls();
  });
});
{'fraction_non_alphanumeric': 0.17972636815920398, 'fraction_numerical': 0.003316749585406302, 'mean_word_length': 3.2548500881834217, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, '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': '1319619', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1546, 'n_words': 341}