<commit_before>import { test, moduleForComponent } from 'ember-qunit';
import Ember from 'ember';
import { openDatepicker } from 'ember-pikaday/helpers/pikaday';

moduleForComponent('pikaday-input', 'PikadayInputComponent', {});

test('is an input tag', function(assert) {
  assert.equal('INPUT', this.$().prop('tagName'));
});

test('the input tag has the readonly attribute if it has been set on the component', function(assert) {
  this.subject({ 'readonly': true });

  assert.ok(this.$().is('[readonly]'));
});

test('clicking the input opens the pikaday dialog', function(assert) {
  this.render();

  assert.ok($('.pika-single').hasClass('is-hidden'));
  openDatepicker(this.$());
  assert.ok(!$('.pika-single').hasClass('is-hidden'));
});

test('selecting a date should update the value attribute', function(assert) {
  var interactor = openDatepicker(this.$());

  interactor.selectDate(new Date(2013, 3, 28));

  var date = this.subject().get('value');

  assert.equal(date.getFullYear(), 2013);
  assert.equal(date.getMonth(), 3);
  assert.equal(date.getDate(), 28);
});

test('setting the value attribute should select the correct date', function(assert) {
  this.subject({ value: new Date(2010, 7, 10) });

  var interactor = openDatepicker(this.$());

  assert.equal(interactor.selectedYear(), 2010);
  assert.equal(interactor.selectedMonth(), 7);
  assert.equal(interactor.selectedDay(), 10);
});

test('DD.MM.YYYY should be the default format for the input', function(assert) {
  this.subject({ value: new Date(2010, 7, 10) });

  assert.equal(this.$().val(), '10.08.2010');
});

test('format of the input is changeable', function(assert) {
  this.subject({ format: 'YYYY.DD.MM', value: new Date(2010, 7, 10) });

  assert.equal(this.$().val(), '2010.10.08');
});

test('theme option adds theme as CSS class to DOM element', function(assert) {
  this.subject({ theme: 'dark-theme' });
  this.render();

  assert.ok($('.pika-single').hasClass('dark-theme'));
});

test('yearRange of the input defaults to 10', function(assert) {
  var interactor = openDatepicker(this.$());
  var currentYear = new Date().getFullYear();

  assert.equal(interactor.minimumYear(), currentYear - 10);
  assert.equal(interactor.maximumYear(), currentYear + 10);
});

test('yearRange of the input can be set with a range', function(assert) {
  this.subject({ yearRange: '4' });
<commit_msg>add unit tests<commit_after>import { test, moduleForComponent } from 'ember-qunit';
import Ember from 'ember';
import { openDatepicker } from 'ember-pikaday/helpers/pikaday';

moduleForComponent('pikaday-input', 'PikadayInputComponent', {});

test('is an input tag', function(assert) {
  assert.equal('INPUT', this.$().prop('tagName'));
});

test('the input tag has the readonly attribute if it has been set on the component', function(assert) {
  this.subject({ 'readonly': true });

  assert.ok(this.$().is('[readonly]'));
});

test('clicking the input opens the pikaday dialog', function(assert) {
  this.render();

  assert.ok($('.pika-single').hasClass('is-hidden'));
  openDatepicker(this.$());
  assert.ok(!$('.pika-single').hasClass('is-hidden'));
});

test('selecting a date should update the value attribute', function(assert) {
  var interactor = openDatepicker(this.$());

  interactor.selectDate(new Date(2013, 3, 28));

  var date = this.subject().get('value');

  assert.equal(date.getFullYear(), 2013);
  assert.equal(date.getMonth(), 3);
  assert.equal(date.getDate(), 28);
});

test('setting the value attribute should select the correct date', function(assert) {
  this.subject({ value: new Date(2010, 7, 10) });

  var interactor = openDatepicker(this.$());

  assert.equal(interactor.selectedYear(), 2010);
  assert.equal(interactor.selectedMonth(), 7);
  assert.equal(interactor.selectedDay(), 10);
});

test('DD.MM.YYYY should be the default format for the input', function(assert) {
  this.subject({ value: new Date(2010, 7, 10) });

  assert.equal(this.$().val(), '10.08.2010');
});

test('format of the input is changeable', function(assert) {
  this.subject({ format: 'YYYY.DD.MM', value: new Date(2010, 7, 10) });

  assert.equal(this.$().val(), '2010.10.08');
});

test('set min date', function(assert) {
  var tomorrow = new Date();
  tomorrow.setDate(tomorrow.getDate() + 1);
  this.subject({minDate: tomorrow});
  this.render();
  openDatepicker(this.$());

  assert.ok($('.is-today').hasClass('is-disabled'));
});

test('set max date', function(assert) {
  var yesterday = new Date();
  yesterday.setDate(yesterday.getDate() - 1);
  this.subject({maxDate: yesterday});
  this.render();
  openDatepicker(this.$());

  assert.ok($('.is-today').hasClass('is-disabled'));
});

test('theme option adds theme as CSS class to DOM element', function(assert) {
  this.subject({ theme: 'dark-theme' });
  this.render();

  assert.ok($('.pika-single').hasClass('dark-theme'));
});

test('yearRange of the input defaults to 10', function(assert) {
  var interactor = openDatepicker(this.$());
  var currentYear = new Date().getFullYear();

  assert.equal(interactor.minimumYear(), currentYear - 10);
  assert.equal(interactor.maximumYear(), currentYear + 10);
});

test('yearRange of the input can be set with a range', function(assert) {
  this.subject({ yearRange: '4' });

{'fraction_non_alphanumeric': 0.1898086758855844, 'fraction_numerical': 0.025004735745406327, 'mean_word_length': 5.168224299065421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3738166', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1644, 'n_words': 412}