<commit_before>import { later } from '@ember/runloop';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

const data = [
  ['Year', 'Sales', 'Expenses'],
  ['2004', 1000, 400],
  ['2005', 1170, 460],
  ['2006', 660, 1120],
  ['2007', 1030, 540],
];

module('Integration | Component | chart options change', function(hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function() {
    this.actions = {};
    this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
  });

  test('Changing options and rerender', async function(assert) {
    assert.expect(2);

    const done = assert.async();

    const title = 'Some legit title';

    this.setProperties({
      data,
      options: { title },
    });

    this.actions.chartDidRender = () => {

      later(() => {
        assert.ok(find('div').innerHTML.indexOf(title) > -1, 'The component should have a title');

        this.set('options', {});

        later(() => {
          assert.ok(find('div').innerHTML.indexOf(title) === -1, 'The component should no longer have a title');

          done();

        }, 100);

      }, 500);

      this.actions.chartDidRender = function() {};

    };

    await render(hbs`{{line-chart data=data options=options chartDidRender=(action 'chartDidRender')}}`);

  });
});
<commit_msg>Test suite passing for Ember CLI 3 update.<commit_after>import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find, settled, waitFor } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

const data = [
  ['Year', 'Sales', 'Expenses'],
  ['2004', 1000, 400],
  ['2005', 1170, 460],
  ['2006', 660, 1120],
  ['2007', 1030, 540],
];

module('Integration | Component | chart options change', function(hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function() {
    this.set('actions', {});
    this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
  });

  test('Changing options and rerender', async function(assert) {
    assert.expect(2);

    const title = 'Some legit title';

    this.setProperties({
      data,
      options: { title },
    });

    await render(hbs`{{line-chart data=data options=options}}`);

    /* Check that the title is correct */

    await waitFor('.google-chart svg');

    assert.ok(find('div').innerHTML.indexOf(title) > -1,
      'The component should have a title');

    const newTitle = 'A new title';

    this.set('options', {
      title: newTitle,
    });

    await settled();

    assert.ok(find('div').innerHTML.indexOf(newTitle) > -1,
      'The component should have a title');

  });
});

{'fraction_non_alphanumeric': 0.1758595988538682, 'fraction_numerical': 0.03617478510028653, 'mean_word_length': 3.3640625, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3133540', 'n_tokens_mistral': 956, 'n_tokens_neox': 858, 'n_words': 218}