<commit_before>import { moduleForComponent } from 'ember-qunit';
import { test, testBS3, testBS4 } from '../../../helpers/bootstrap-test';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('bs-popover/element', 'Integration | Component | bs-popover/element', {
  integration: true
});

testBS3('it has correct markup', function(assert) {
  // Template block usage:
  this.render(hbs`
    {{#bs-popover/element fade=true in=true title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);

  assert.ok(this.$(':first-child').hasClass('popover'), 'has popover class');
  assert.ok(this.$(':first-child').hasClass('top'), 'has top class');
  assert.ok(this.$(':first-child').hasClass('fade'), 'has fade class');
  assert.ok(this.$(':first-child').hasClass('in'), 'has in class');
  assert.equal(this.$('.arrow').length, 1, 'has arrow');
  assert.equal(this.$('.popover-title').text().trim(), 'dummy title', 'shows title');
  assert.equal(this.$('.popover-content').text().trim(), 'template block text', 'shows content');
});

testBS4('it has correct markup', function(assert) {
  // Template block usage:
  this.render(hbs`
    {{#bs-popover/element fade=true in=true title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);

  assert.ok(this.$(':first-child').hasClass('popover'), 'has popover class');
  assert.ok(this.$(':first-child').hasClass('popover-top'), 'has popover-top class');
  assert.ok(this.$(':first-child').hasClass('fade'), 'has fade class');
  assert.ok(this.$(':first-child').hasClass('show'), 'has show class');
  assert.equal(this.$('.arrow').length, 1, 'has arrow');
  assert.equal(this.$('.popover-title').text().trim(), 'dummy title', 'shows title');
  assert.equal(this.$('.popover-content').text().trim(), 'template block text', 'shows content');
});

testBS3('it supports different placements', function(assert) {
  let placements = ['top', 'left', 'bottom', 'right'];
  this.render(hbs`
    {{#bs-popover/element placement=placement title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);
  placements.forEach((placement) => {
    this.set('placement', placement);
    assert.ok(this.$(':first-child').hasClass(placement), `has ${placement} class`);
  });
});

testBS4('it supports different placements', function(assert) {
  let placements = ['top', 'left', 'bottom', 'right'];
  this.render(hbs`
    {{#bs-popover/element placement=placement title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);
  placements.forEach((placement) => {
    this.set('placement', placement);
    let expectedClass = `popover-${placement}`;
    assert.ok(this.$(':first-child').hasClass(expectedClass), `has ${expectedClass} class`);
  });
});

test('it passes along class attribute', function(assert) {
  this.render(hbs`
    {{#bs-popover/element placement=placement title="dummy title" class="wide"}}
      template block text
    {{/bs-popover/element}}<commit_msg>Apply test helpers to popover element tests.<commit_after>import { moduleForComponent } from 'ember-qunit';
import { placementClassFor, test, visibilityClass } from '../../../helpers/bootstrap-test';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('bs-popover/element', 'Integration | Component | bs-popover/element', {
  integration: true
});

test('it has correct markup', function(assert) {
  // Template block usage:
  this.render(hbs`
    {{#bs-popover/element fade=true in=true title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);

  assert.ok(this.$(':first-child').hasClass('popover'), 'has popover class');
  assert.ok(this.$(':first-child').hasClass(placementClassFor('popover', 'top')), 'has placement class');
  assert.ok(this.$(':first-child').hasClass('fade'), 'has fade class');
  assert.ok(this.$(':first-child').hasClass(visibilityClass()), 'has visibility class');
  assert.equal(this.$('.arrow').length, 1, 'has arrow');
  assert.equal(this.$('.popover-title').text().trim(), 'dummy title', 'shows title');
  assert.equal(this.$('.popover-content').text().trim(), 'template block text', 'shows content');
});

test('it supports different placements', function(assert) {
  let placements = ['top', 'left', 'bottom', 'right'];
  this.render(hbs`
    {{#bs-popover/element placement=placement title="dummy title"}}
      template block text
    {{/bs-popover/element}}
  `);
  placements.forEach((placement) => {
    this.set('placement', placement);
    let placementClass = placementClassFor('popover', placement);
    assert.ok(this.$(':first-child').hasClass(placementClass), `has ${placementClass} class`);
  });
});

test('it passes along class attribute', function(assert) {
  this.render(hbs`
    {{#bs-popover/element placement=placement title="dummy title" class="wide"}}
      template block text
    {{/bs-popover/element}}
{'fraction_non_alphanumeric': 0.2027800490596893, 'fraction_numerical': 0.001839738348323794, 'mean_word_length': 4.902291917973462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '133445', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1517, 'n_words': 313}