<commit_before>import {
  it,
  inject,
  injectAsync,
  describe,
  beforeEach,
  beforeEachProviders,
  TestComponentBuilder
} from 'angular2/testing';
import { provide } from 'angular2/core';

import { Task } from '../models/task';
import { TaskComponent } from './task.component';
import { TaskService } from '../services/task.service';
import { TaskProvider } from '../services/mock-tasks';

class MockTaskProvider {
  public tasks: Task[] = [
    new Task('Task1', 'Note1', new Date(2016, 5, 14)),
    new Task('Task2', 'Note2', new Date(2016, 5, 20))
  ]
}

describe('TaskComponent', () => {
  let tcb, taskService;

  beforeEachProviders(() => [
    provide(
      TaskProvider, { useClass: MockTaskProvider }
    ),
    TaskComponent,
    TaskService,
    TestComponentBuilder
  ]);

  beforeEach(inject([TestComponentBuilder, TaskService], (builder, service) => {
    tcb = builder;
    taskService = service;
  }));

  it('renders a task', done => {
    tcb.createAsync(TaskComponent)
      .then(fixture => {
        let component = fixture.componentInstance,
            element = fixture.nativeElement,
            task = taskService.list()[0];
        component.task = task;
        fixture.detectChanges();
        expect(element.querySelector('.task-title').innerText).toBe(task.title);
        expect(element.querySelector('time').innerText).toBe(task.dueDate.toString());
        done();
      })
      .catch(e => done.fail(e));
  })

  it('can mark a task complete', done => {
    tcb.createAsync(TaskComponent)
      .then(fixture => {
        let component = fixture.componentInstance,
            element = fixture.nativeElement,
            task: Task = taskService.list()[0];
        component.task = task;
        fixture.detectChanges();
        expect(element.querySelector('#isCompleted').checked).toBeFalsy();
        component.markCompleted();
        fixture.detectChanges();
        expect(task.isCompleted).toBeTruthy();
        done();
      })
      .catch(e => done.fail(e));;
  });

  it('can remove a task', done => {
    tcb.createAsync(TaskComponent)
     .then(fixture => {
       let component = fixture.componentInstance,
           element = fixture.nativeElement,
           task = taskService.list()[0];
       component.task = task;
       fixture.detectChanges();
       expect(component.task).not.toBeNull();
       component.removeTask();
       fixture.detectChanges();
       expect(taskService.list().length).toBe(0);
       done();
     })
     .catch(e => done.fail(e));;
  });
  
  it('can prioritise a task', done => {
    tcb.createAsync(TaskComponent)
     .then(fixture => {
       let component = fixture.componentInstance,
           element = fixture.nativeElement,
           task = taskService.list()[1];
       component.task = task;
       fixture.detectChanges();
       expect(element.querySelector('#isPrioritised').checked).toBeFalsy();
       component.prioritised();
       fixture.detectChanges();
       expect(task.isPrioritised).toBeTruthy();
       done();
     })
     .catch(e => done.fail(e));;
  });
});
<commit_msg>change to select on class<commit_after>import {
  it,
  inject,
  injectAsync,
  describe,
  beforeEach,
  beforeEachProviders,
  TestComponentBuilder
} from 'angular2/testing';
import { provide } from 'angular2/core';

import { Task } from '../models/task';
import { TaskComponent } from './task.component';
import { TaskService } from '../services/task.service';
import { TaskProvider } from '../services/mock-tasks';

class MockTaskProvider {
  public tasks: Task[] = [
    new Task('Task1', 'Note1', new Date(2016, 5, 14)),
    new Task('Task2', 'Note2', new Date(2016, 5, 20))
  ]
}

describe('TaskComponent', () => {
  let tcb, taskService;

  beforeEachProviders(() => [
    provide(
      TaskProvider, { useClass: MockTaskProvider }
    ),
    TaskComponent,
    TaskService,
    TestComponentBuilder
  ]);

  beforeEach(inject([TestComponentBuilder, TaskService], (builder, service) => {
    tcb = builder;
    taskService = service;
  }));

  it('renders a task', done => {
    tcb.createAsync(TaskComponent)
      .then(fixture => {
        let component = fixture.componentInstance,
            element = fixture.nativeElement,
            task = taskService.list()[0];
        component.task = task;
        fixture.detectChanges();
        expect(element.querySelector('.task-title').innerText).toBe(task.title);
        expect(element.querySelector('time').innerText).toBe(task.dueDate.toString());
        done();
      })
      .catch(e => done.fail(e));
  })

  it('can mark a task complete', done => {
    tcb.createAsync(TaskComponent)
      .then(fixture => {
        let component = fixture.componentInstance,
            element = fixture.nativeElement,
            task: Task = taskService.list()[0];
        component.task = task;
        fixture.detectChanges();
        expect(element.querySelector('.isCompleted').checked).toBeFalsy();
        component.markCompleted();
        fixture.detectChanges();
        expect(task.isCompleted).toBeTruthy();
        done();
      })
      .catch(e => done.fail(e));;
  });

  it('can remove a task', done => {
    tcb.createAsync(TaskComponent)
     .then(fixture => {
       let component = fixture.componentInstance,
           element = fixture.nativeElement,
           task = taskService.list()[0];
       component.task = task;
       fixture.detectChanges();
       expect(component.task).not.toBeNull();
       component.removeTask();
       fixture.detectChanges();
       expect(taskService.list().length).toBe(0);
       done();
     })
     .catch(e => done.fail(e));;
  });
  
  it('can prioritise a task', done => {
    tcb.createAsync(TaskComponent)
     .then(fixture => {
       let component = fixture.componentInstance,
           element = fixture.nativeElement,
           task = taskService.list()[1];
       component.task = task;
       fixture.detectChanges();
       expect(element.querySelector('.isPrioritised').checked).toBeFalsy();
       component.prioritised();
       fixture.detectChanges();
       expect(task.isPrioritised).toBeTruthy();
       done();
     })
     .catch(e => done.fail(e));;
  });
});

{'fraction_non_alphanumeric': 0.15035415325177076, 'fraction_numerical': 0.008048937540244688, 'mean_word_length': 2.7586206896551726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '7541457', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1784, 'n_words': 332}