<commit_before>import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

const { Object, RSVP } = Ember;
const { resolve } = RSVP;

moduleForComponent('programyear-objective-list-item', 'Integration | Component | programyear objective list item', {
  integration: true
});

test('it renders', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'nothing')
  }}`);

  assert.equal(this.$('td:eq(0)').text().trim(), 'fake title');
  assert.equal(this.$('td:eq(1) button').text().trim(), 'Add New');
  assert.equal(this.$('td:eq(2) button').text().trim(), 'Add New');
});


test('can change title', function(assert) {
  let objective = Object.create({
    title: 'fake title',
    save(){
      assert.equal(this.get('title'), '<p>new title</p>');
      return resolve();
    }
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'nothing')
  }}`);

  this.$('td:eq(0) .editable').click();
  this.$('td:eq(0) .froalaEditor').froalaEditor('html.set', 'new title');
  this.$('td:eq(0) .froalaEditor').froalaEditor('events.trigger', 'contentChanged');
  this.$('td:eq(0) .done').click();

});

test('can manage competency', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);
  this.on('something', ()=>{
    assert.ok(true);
  });

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'something')
  }}`);

  this.$('td:eq(1) button').click();

});

test('can manage descriptors', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);
  this.on('something', ()=>{
    assert.ok(true);
  });

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'something')
    manageCompetency=(action 'nothing')
  }}`);

  this.$('td:eq(2) button').click();

});
<commit_msg>updated tests.<commit_after>import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

const { Object, RSVP } = Ember;
const { resolve } = RSVP;

moduleForComponent('programyear-objective-list-item', 'Integration | Component | programyear objective list item', {
  integration: true
});

test('it renders', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'nothing')
    editable=true
  }}`);

  assert.equal(this.$('td:eq(0)').text().trim(), 'fake title');
  assert.equal(this.$('td:eq(1) button').text().trim(), 'Add New');
  assert.equal(this.$('td:eq(2) button').text().trim(), 'Add New');
});


test('can change title', function(assert) {
  let objective = Object.create({
    title: 'fake title',
    save(){
      assert.equal(this.get('title'), '<p>new title</p>');
      return resolve();
    }
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'nothing')
    editable=true
  }}`);

  this.$('td:eq(0) .editable').click();
  this.$('td:eq(0) .froalaEditor').froalaEditor('html.set', 'new title');
  this.$('td:eq(0) .froalaEditor').froalaEditor('events.trigger', 'contentChanged');
  this.$('td:eq(0) .done').click();

});

test('can manage competency', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);
  this.on('something', ()=>{
    assert.ok(true);
  });

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'nothing')
    manageCompetency=(action 'something')
    editable=true
  }}`);

  this.$('td:eq(1) button').click();

});

test('can manage descriptors', function(assert) {
  let objective = Object.create({
    title: 'fake title'
  });
  this.set('objective', objective);
  this.on('nothing', parseInt);
  this.on('something', ()=>{
    assert.ok(true);
  });

  this.render(hbs`{{programyear-objective-list-item
    objective=objective
    remove=(action 'nothing')
    manageDescriptors=(action 'something')
    manageCompetency=(action 'nothing')
    editable=true
  }}`);

  this.$('td:eq(2) button').click();

});

{'fraction_non_alphanumeric': 0.19624736741336396, 'fraction_numerical': 0.0034462952326249283, 'mean_word_length': 4.587165775401069, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6890086', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1705, 'n_words': 305}