/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');

const ExpandingProgress = require('./expanding-progress');

const jsTestUtils = require('../../utils/component-test-utils');
const testUtils = require('react-dom/test-utils');

describe('ExpandingProgress', function() {

  it('renders properly', () => {
    var output = jsTestUtils.shallowRender(
      <ExpandingProgress />);
    var expected = (
      <div className="expanding-progress"></div>);
    assert.deepEqual(output, expected);
  });

  it('adds the active class after mounted', done => {
    var component = testUtils.renderIntoDocument(
      <ExpandingProgress />);
    // The class is set asynchronously so loop over the value and continue When
    // it changes.
    setTimeout(() => {
      if (component.state.active) {
        assert.equal(component.state.active, true);
        done();
      }
    });
  });

});

/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');
const enzyme = require('enzyme');

const ExpandingProgress = require('./expanding-progress');

describe('ExpandingProgress', function() {

  const renderComponent = (options = {}) => enzyme.shallow(
    <ExpandingProgress />
  );

  beforeEach(() => {
    this.clock = sinon.useFakeTimers();
  });

  afterEach(() => {
    this.clock.restore();
  });

  it('renders properly', () => {
    const wrapper = renderComponent();
    var expected = (
      <div className="expanding-progress"></div>);
    assert.compareJSX(wrapper, expected);
  });

  it('adds the active class after mounted', () => {
    const wrapper = renderComponent();
    // The class is set asynchronously fast forward until it should be applied.
    this.clock.tick(1);
    wrapper.update();
    assert.equal(
      wrapper.prop('className').includes('expanding-progress--active'),
      true);
  });

});

Update expanding progress tests to use enzyme.
Update expanding progress tests to use enzyme.
