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


let mockEvents;
let userEventsMock;
let blankEventsMock;

module('Integration | Component | dashboard agenda', function(hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function() {
    let today = moment();
    mockEvents = [
      {name: 'first', startDate: today.format(), location: 123, lastModified: today.format(), attendanceRequired: true, equipmentRequired: true, attireRequired: true},
      {name: 'second', startDate: today.format(), location: 456, lastModified: today.format(), attendanceRequired: false, equipmentRequired: false, attireRequired: false},
      {name: 'third', startDate: today.format(), location: 789, lastModified: today.format(), attendanceRequired: false, equipmentRequired: false, attireRequired: false},
    ];
    userEventsMock = Service.extend({
      getEvents(){
        return new resolve(mockEvents);
      }
    });
    blankEventsMock = Service.extend({
      getEvents(){
        return new resolve([]);
      }
    });
  });

  test('it renders with events', async function(assert) {
    assert.expect(7);
    this.owner.register('service:user-events', userEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    const title = 'h3';

    return settled().then(()=>{
      assert.dom(this.element.querySelector(title)).hasText('My Activities for the next 60 days');
      for(let i = 0; i < 3; i++){
        let tds = this.element.querySelectorAll(`table tr:nth-of-type(${i + 1}) td`);
        assert.dom(tds[0]).hasText(moment(mockEvents[i].startDate).format('dddd, MMMM Do, YYYY h:mma'));
        assert.dom(tds[1]).hasText(mockEvents[i].name);
      }
    });
  });

  test('session attribute icons', async function(assert) {
    assert.expect(6);
    this.owner.register('service:user-events', userEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    return settled().then(()=>{
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-black-tie').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-flask').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-calendar-check').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-black-tie').length, 0);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-flask').length, 0);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-calendar-check').length, 0);
    });
  });

  test('it renders blank', async function(assert) {
    assert.expect(2);
    this.owner.register('service:user-events', blankEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    const title = 'h3';
    const body = 'p';

    return settled().then(()=>{
      assert.dom(this.element.querySelector(title)).hasText('My Activities for the next 60 days');
      assert.dom(this.element.querySelector(body)).hasText('None');
    });
  });
});<commit_msg>fixes up existing test.<commit_after>import {resolve} from 'rsvp';
import Service from '@ember/service';
import {module, test} from 'qunit';
import {setupRenderingTest} from 'ember-qunit';
import {render, settled} from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import moment from 'moment';


let mockEvents;
let userEventsMock;
let blankEventsMock;

module('Integration | Component | dashboard agenda', function (hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function () {
    let today = moment();
    mockEvents = [
      {
        name: 'first',
        startDate: today.format(),
        location: 123,
        lastModified: today.format(),
        attendanceRequired: true,
        equipmentRequired: true,
        attireRequired: true,
        postrequisites: [],
      },
      {
        name: 'second',
        startDate: today.format(),
        location: 456,
        lastModified: today.format(),
        attendanceRequired: false,
        equipmentRequired: false,
        attireRequired: false,
        postrequisites: [],
      },
      {
        name: 'third',
        startDate: today.format(),
        location: 789,
        lastModified: today.format(),
        attendanceRequired: false,
        equipmentRequired: false,
        attireRequired: false,
        postrequisites: [],
      },
    ];
    userEventsMock = Service.extend({
      getEvents() {
        return new resolve(mockEvents);
      },
    });
    blankEventsMock = Service.extend({
      getEvents() {
        return new resolve([]);
      },
    });
  });

  test('it renders with events', async function (assert) {
    assert.expect(7);
    this.owner.register('service:user-events', userEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    const title = 'h3';

    return settled().then(() => {
      assert.dom(this.element.querySelector(title)).hasText('My Activities for the next 60 days');
      for (let i = 0; i < 3; i++) {
        let tds = this.element.querySelectorAll(`table tr:nth-of-type(${i + 1}) td`);
        assert.dom(tds[0]).hasText(moment(mockEvents[i].startDate).format('dddd, MMMM Do, YYYY h:mma'));
        assert.dom(tds[1]).hasText(mockEvents[i].name);
      }
    });
  });

  test('session attribute icons', async function (assert) {
    assert.expect(6);
    this.owner.register('service:user-events', userEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    return settled().then(() => {
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-black-tie').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-flask').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(1) td:nth-of-type(4) .fa-calendar-check').length, 1);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-black-tie').length, 0);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-flask').length, 0);
      assert.equal(this.element.querySelectorAll('table tr:nth-of-type(2) td:nth-of-type(4) .fa-calendar-check').length, 0);
    });
  });

  test('it renders blank', async function (assert) {
    assert.expect(2);
    this.owner.register('service:user-events', blankEventsMock);
    this.userEvents = this.owner.lookup('service:user-events');

    await render(hbs`{{dashboard-agenda}}`);
    const title = 'h3';
    const body = 'p';

    return settled().then(() => {
      assert.dom(this.element.querySelector(title)).hasText('My Activities for the next 60 days');
      assert.dom(this.element.querySelector(body)).hasText('None');
    });
  });
});
{'fraction_non_alphanumeric': 0.1672077922077922, 'fraction_numerical': 0.011093073593073594, 'mean_word_length': 3.632205513784461, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3517416', 'n_tokens_mistral': 2361, 'n_tokens_neox': 2340, 'n_words': 443}