<commit_before>import Service from '@ember/service';
import RSVP from 'rsvp';
import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, settled, find } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

const { resolve, reject } = RSVP;

module('helper:report-title', function(hooks) {
  setupRenderingTest(hooks);

  test('custom title', async function(assert) {
    assert.expect(1);
    const report = EmberObject.create({
      'title': 'Lorem Ipsum'
    });
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    return settled().then(()=>{
      assert.equal(find('*').textContent.trim(), report.get('title'));
    });
  });

  test('all competencies in all schools', async function(assert) {
    assert.expect(1);
    const report = EmberObject.create({
      'prepositionalObject': null,
      'school': null,
      'subject': 'competency',
      'title': null,
    });
    const storeMock = Service.extend({});
    this.owner.register('service:store', storeMock);
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    return settled().then(()=>{
      assert.equal(find('*').textContent.trim(), 'All Competencies in All Schools');
    });
  });

  test('all competencies in school X', async function(assert) {
    assert.expect(1);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const report = EmberObject.create({
      'prepositionalObject': null,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
    });
    const storeMock = Service.extend({});
    this.owner.register('service:store', storeMock);
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    return settled().then(()=>{
      assert.equal(find('*').textContent.trim(), 'All Competencies in ' + school.get('title'));
    });
  });

  test('all competencies for user X in school Y', async function(assert) {
    assert.expect(3);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const pObject = EmberObject.create({
      dasherize(){
        return 'user';
      }
    });
    const userRecord = EmberObject.create({
      fullName: '<NAME>',
    });
    const report = EmberObject.create({
      'prepositionalObject': pObject,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
      'prepositionalObjectTableRowId': 1,
    });

    const storeMock = Service.extend({
      findRecord(model, id) {
        assert.equal(model, 'user');
        assert.equal(id, 1);
        return resolve(userRecord);
      }
    });

    this.owner.register('service:store', storeMock);
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    return settled().then(()=>{
      assert.equal(find('*').textContent.trim(), 'All Competencies for ' + userRecord.get('fullName') +  ' in ' + school.get('title'));
    });
  });

  test('broken report', async function(assert) {
    assert.expect(1);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const pObject = EmberObject.create({
      dasherize(){
        return 'user';
      }
    });
    const report = EmberObject.create({
      'prepositionalObject': pObject,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
      'prepositionalObjectTableRowId': 1,
    });
    const storeMock = Service.extend({
      findRecord() {
        return reject(new Error('not found'));
      }
    });
    this.owner.register('service:store', storeMock);
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    return settled().then(()=>{
      assert.equal(find('*').textContent.trim(), '');
    });
  });
});<commit_msg>Fix test to remove store mock<commit_after>import RSVP from 'rsvp';
import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';

const { resolve, reject } = RSVP;

module('helper:report-title', function(hooks) {
  setupRenderingTest(hooks);
  setupMirage(hooks);

  test('custom title', async function(assert) {
    assert.expect(1);
    const report = EmberObject.create({
      'title': 'Lorem Ipsum'
    });
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    assert.equal(this.element.textContent.trim(), report.get('title'));
  });

  test('all competencies in all schools', async function(assert) {
    assert.expect(1);
    const report = EmberObject.create({
      'prepositionalObject': null,
      'school': null,
      'subject': 'competency',
      'title': null,
    });
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    assert.equal(this.element.textContent.trim(), 'All Competencies in All Schools');
  });

  test('all competencies in school X', async function(assert) {
    assert.expect(1);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const report = EmberObject.create({
      'prepositionalObject': null,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
    });
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    assert.equal(this.element.textContent.trim(), 'All Competencies in ' + school.get('title'));
  });

  test('all competencies for user X in school Y', async function(assert) {
    assert.expect(1);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const pObject = EmberObject.create({
      dasherize(){
        return 'user';
      }
    });
    const report = EmberObject.create({
      'prepositionalObject': pObject,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
      'prepositionalObjectTableRowId': 1,
    });
    this.server.create('user');
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    assert.equal(this.element.textContent.trim(), 'All Competencies for 0 guy <NAME> in ' + school.get('title'));
  });

  test('broken report', async function(assert) {
    assert.expect(1);
    const school = EmberObject.create({
      'title': 'School of Schools'
    });
    const pObject = EmberObject.create({
      dasherize(){
        return 'user';
      }
    });
    const report = EmberObject.create({
      'prepositionalObject': pObject,
      'school': resolve(school),
      'subject': 'competency',
      'title': null,
      'prepositionalObjectTableRowId': 1,
    });
    this.set('report', report);
    await render(hbs`{{report-title report}}`);
    assert.equal(this.element.textContent.trim(), '');
  });
});
{'fraction_non_alphanumeric': 0.16889080212369062, 'fraction_numerical': 0.0022958817620892524, 'mean_word_length': 3.3211407315561066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '126288', 'n_tokens_mistral': 2111, 'n_tokens_neox': 2138, 'n_words': 471}