test('when button clicked proper action gets fired', function(assert) {
  assert.expect(5);
  const title = 'Title';
  const content = 'content';
  const solution = 'solution';
  this.set('onSubmit', (formData) => {
    assert.equal(formData.title, title);
    assert.equal(formData.content, content);
    assert.equal(formData.solution, solution);
    assert.equal(formData.category.id, 1);
    assert.equal(formData.category.title, 'Foo');
  });

  this.render(hbs `{{challenge-form
    onSubmit=(action onSubmit)
    categories=categories
  }}`);
  fillInBlurIntegration(this, '.js-title', title);
  fillInBlurIntegration(this, '.js-content', content, 'textarea');
  fillInBlurIntegration(this, '.js-solution', solution, 'textarea');
  clickTrigger();
  nativeMouseUp('.ember-power-select-option:eq(0)');
  this.$('.js-category').trigger('blur');
  this.$('form').submit();
});
test('it validates category select field', function(assert) {
  this.render(hbs `{{challenge-form
    categories=categories
    onSubmit=(action onSubmit)
  }}`);
  clickTrigger();
  typeInSearch('asd');
  this.$('.js-category').trigger('blur');
  Ember.run.next(() => {
    assert.ok(this.$('.js-category').hasClass('has-error'), 'select should have an error');
  });
});
test('it enables submit when all fields valid', function(assert) {
  this.render(hbs `{{challenge-form
    categories=categories
    onSubmit=(action onSubmit)
  }}`);
  fillInBlurIntegration(this, '.js-title', '');
  fillInBlurIntegration(this, '.js-content', '', 'textarea');
  fillInBlurIntegration(this, '.js-solution', '', 'textarea');
  this.$('.js-category').trigger('blur');
  assert.ok(this.$('button[type=submit]').is(':disabled'), 'button should be disabled');
  fillInBlurIntegration(this, '.js-title', 'Title');
  fillInBlurIntegration(this, '.js-content', 'Content', 'textarea');
  fillInBlurIntegration(this, '.js-solution', 'Solution', 'textarea');
  clickTrigger();
  nativeMouseUp('.ember-power-select-option:eq(0)');
  this.$('.js-category').trigger('blur');
});