Sha256: 6bd02621ce6a1ee352ffd36eebb95196da6c0195ecb51d0b67e7a146a2c3f351

Contents?: true

Size: 1.83 KB

Versions: 44

Compression:

Stored size: 1.83 KB

Contents

/* eslint-disable jquery/no-size */

import $ from 'jquery';

import { checkForUnavailablePuppetclasses } from './foreman_puppet_host_form';

jest.unmock('jquery');
jest.unmock('./foreman_puppet_host_form');

describe('checkForUnavailablePuppetclasses', () => {
  beforeEach(() => {
    document.body.innerHTML = `<div>
        <ul class="nav-tabs">
          <li><a href="#puppet_enc_tab" data-toggle="tab">Puppet Classes</a></li>
        </ul>
        <div class="tab-content">
          <form>
            <div class="tab-pane active" id="hostgroup">
                <div class="form-group">
                  <div>
                    <input id="hostgroup_environment_id"/>
                  </div>
                  <span class="help-block"></span>
                </div>
            </div>
            <div class="tab-pane" id="puppet_enc_tab">
              <div id="selected_classes"></div>
            </div>
          </form>
        </div>
      </div>`;
  });

  it('adds a warning if an unavailable class is found', () => {
    $('#selected_classes').append(
      '<li class="unavailable">Unavailable Class</li>'
    );

    checkForUnavailablePuppetclasses();
    expect($('#puppetclasses_unavailable_warning').size()).toBe(1);
  });

  it('does not add a warning if no unavailable classes are found', () => {
    $('#hostgroup .help-block').empty();
    $('#selected_classes').empty();

    checkForUnavailablePuppetclasses();
    expect(
      $('#hostgroup .help-block')
        .first()
        .children()
        .size()
    ).toBe(0);
  });

  it('adds a warning sign to the tab if unavailable classes are found', () => {
    $('#selected_classes').append(
      '<li class="unavailable">Unavailable Class</li>'
    );
    checkForUnavailablePuppetclasses();
    setTimeout(() => {
      expect($('a .pficon').size()).toBe(1);
    }, 100);
  });
});

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
foreman_puppet-6.3.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-6.2.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-6.1.1 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-5.1.3 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-6.1.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-6.0.1 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-6.0.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-5.1.2 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.1.1 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-5.1.1 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-5.1.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.1.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.0.4 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-5.0.0 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.0.3 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.0.2 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-3.0.7 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-2.0.7 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.0.1 webpack/src/foreman_puppet_host_form.test.js
foreman_puppet-4.0.0 webpack/src/foreman_puppet_host_form.test.js