/* global moment */
import Ember from "ember";
import startApp from '../helpers/start-app';
import { test, moduleForComponent } from 'ember-qunit';

var App, component;

moduleForComponent('bs-datetimepicker', 'ember-bootstrap-datetimepicker integration', {
  setup: function() {
    App = startApp();
  },
  teardown: function() {
    Ember.run(App, 'destroy');
    // clear up component (this should be done by ember-qunit soon!)
    if (component) {
      Ember.run(component, 'destroy');
      component = null;
    }
  }
});

test("it shows the picker on input focus, then hides it after click outside", function(assert) {
  assert.expect(3);
  component = this.subject();

  // initial render
  this.$();

  andThen(function() {
    assert.equal($(".bootstrap-datetimepicker-widget").css("display"), undefined, "date picker is initially a hidden");
    click($(".input-group-addon"));
  });



  andThen(function() {
    assert.equal($(".bootstrap-datetimepicker-widget").css("display"), "block", "date picker is visible");
    click($(".input-group-addon"));
  });

  andThen(function() {
    assert.equal($(".bootstrap-datetimepicker-widget").css("display"), undefined, "date picker is hidden again");
  });
});

@@ -1209,12 +1209,496 @@
 ;%0A  %7D);%0A%7D);%0A
+%0A%0Atest(%22test the 'showClear' option%22, function(assert) %7B%0A  assert.expect(2);%0A  component = this.subject(%7B%0A    useCurrent: true,%0A    showClear: true%0A  %7D);%0A%0A  // initial render%0A  this.$();%0A%0A  andThen(function() %7B%0A    click($(%22.input-group-addon%22));%0A  %7D);%0A%0A  andThen(function() %7B%0A    assert.notEqual(component.get('date'), null);%0A  %7D);%0A%0A  andThen(function() %7B%0A    click($(%22a%5Bdata-action='clear'%5D%22));%0A  %7D);%0A%0A  andThen(function() %7B%0A    assert.equal(component.get('date'), null);%0A  %7D);%0A%7D);%0A

add testcase for 'showClear' option