{"size": 1365, "ext": "js", "max_stars_repo_path": "tests/acceptance/many-tooltips-test.js", "max_stars_repo_name": "raido/ember-tooltips", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/acceptance/many-tooltips-test.js", "max_issues_repo_name": "raido/ember-tooltips", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/acceptance/many-tooltips-test.js", "max_forks_repo_name": "raido/ember-tooltips", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.3, "max_line_length": 115, "alphanum_fraction": 0.6798534799}
import {
  currentURL,
  settled,
  triggerEvent,
  visit
} from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import {
  assertTooltipNotRendered,
  assertTooltipRendered,
  assertTooltipVisible,
} from 'ember-tooltips/test-support/dom/assertions';

module('Acceptance | many-tooltips', function(hooks) {
  setupApplicationTest(hooks);

  test('does not raise infinite render invalidation errors when destroying many tooltips', async function(assert) {
    assert.expect(63);

    await visit('/many-tooltips');
    assert.equal(currentURL(), '/many-tooltips');

    assertTooltipNotRendered(assert);

    const tooltips = new Uint8Array(15).reduce((acc, _, i) => {
      acc.push(`.tooltip-${i + 1}`);
      return acc;
    }, []);

    for (const tooltip of tooltips) {
      const tooltipTarget = document.querySelector(`${tooltip}-target`);
      const tooltipOptions = {
        selector: tooltip,
      };

      assert.ok(tooltipTarget, 'there should be one $tooltipTarget');
      assertTooltipNotRendered(assert, tooltipOptions);
      await triggerEvent(tooltipTarget, 'mouseenter');
      assertTooltipRendered(assert, tooltipOptions);
      assertTooltipVisible(assert, tooltipOptions);
    }

    await settled();
    await visit('/');

    assert.equal(currentURL(), '/');
  });
});
