Sha256: 60424a355786c8ad96449eb614a180cab464069fbc322d946d2f8dcfd7353c0b

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

/* eslint-disable jquery/no-val */
/* eslint-disable jquery/no-is */

import $ from 'jquery';

jest.unmock('jquery');
jest.unmock('./trends');
window.trends = require('./trends');

describe('selecting trend type', () => {
  it('should disable fields on non-fact trend', () => {
    document.body.innerHTML = `<select id="trendable_type" onchange="trends.trendTypeSelected(this)">
      <option value="FactName">Facts</option>
      <option value="Hostgroup">Host group</option>
    </select>
    <select id="trend_trendable_id">
      <option value=""></option>
      <option value="27">architecture</option>
    </select>
    <input id="trend_name">`;
    $('#trendable_type')
      .val('Hostgroup')
      .change();
    expect($('#trend_trendable_id').is(':disabled')).toBeTruthy();
    expect($('#trend_name').is(':disabled')).toBeTruthy();
  });

  it('should enable fields on non-fact trend', () => {
    document.body.innerHTML = `<select id="trendable_type" onchange="trends.trendTypeSelected(this)">
      <option value="Evironment">Environment</option>
      <option value="FactName">Facts</option>
    </select>
    <select id="trend_trendable_id" disabled>
      <option value=""></option>
      <option value="27">architecture</option>
    </select>
    <input id="trend_name" disabled>`;
    $('#trendable_type')
      .val('FactName')
      .change();
    expect($('#trend_trendable_id').is(':disabled')).toBeFalsy();
    expect($('#trend_name').is(':disabled')).toBeFalsy();
  });
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_statistics-2.1.0 webpack/src/trends.test.js
foreman_statistics-2.0.1 webpack/src/trends.test.js
foreman_statistics-2.0.0 webpack/src/trends.test.js
foreman_statistics-1.2.0 webpack/src/trends.test.js
foreman_statistics-1.1.1 webpack/src/trends.test.js
foreman_statistics-1.1.0 webpack/src/trends.test.js
foreman_statistics-1.0.0 webpack/src/trends.test.js
foreman_statistics-0.1.3 webpack/src/trends.test.js
foreman_statistics-0.1.2 webpack/src/trends.test.js