<commit_before>import { Logger } from './../shared/logger.service';
import { cloneDeep } from 'lodash';
import { IterationModel } from './../models/iteration.model';
import { AuthenticationService } from './../auth/authentication.service';
import {
  BaseRequestOptions,
  Http,
  Response,
  ResponseOptions
} from '@angular/http';
import {
  async,
  inject,
  TestBed
} from '@angular/core/testing';
import { MockBackend } from '@angular/http/testing';
import { IterationService } from './iteration.service';

describe ('Iteration service - ', () => {
  let apiService: IterationService;
  let mockService: MockBackend;

  let fakeAuthService: any;

  beforeEach(() => {
    fakeAuthService = {
      getToken: function () {
        return '';
      },
      isLoggedIn: function() {
        return true;
      }
    };

    TestBed.configureTestingModule({
      providers: [
        Logger,
        BaseRequestOptions,
        MockBackend,
        {
          provide: Http,
          useFactory: (backend: MockBackend,
                       options: BaseRequestOptions) => new Http(backend, options),
          deps: [MockBackend, BaseRequestOptions]
        },
        {
          provide: AuthenticationService,
          useValue: fakeAuthService
        },
        IterationService
      ]
    });
  });

  beforeEach(inject(
    [IterationService, MockBackend],
    (service: IterationService, mock: MockBackend) => {
      apiService = service;
      mockService = mock;
    }
  ));

  let resp: IterationModel[] = [{
      attributes: {
        endAt: '2016-11-29T23:18:14Z',
        name: 'Sprint #24',
        startAt: '2016-11-29T23:18:14Z'
      },
      id: 'd8535583-dfbd-4b62-be8d-44a7d4fa7048',
      links: {
        self: 'http://localhost:8080/api/iterations/d8535583-dfbd-4b62-be8d-44a7d4fa7048'
      },
      relationships: {
        space: {
          data: {
            id: 'd7d98b45-415a-4cfc-add2-ec7b7aee7dd5',
            type: 'spaces'
          },
          links: {
            self: 'http://localhost:8080/api/spaces/d7d98b45-415a-4cfc-add2-ec7b7aee7dd5'
          }
        }
      },
      type: 'iterations'
  }];
  let response = {data: resp, links: {}};
  let checkResp = cloneDeep(resp);

  it('Get iterations', async(() => {
    mockService.connections.subscribe((connection: any) => {
      connection.mockRespond(new Response(
        new ResponseOptions({
          body: JSON.stringify(response),<commit_msg>fixes #972 - add missing required field to unit test (#973)<commit_after>import { Logger } from './../shared/logger.service';
import { cloneDeep } from 'lodash';
import { IterationModel } from './../models/iteration.model';
import { AuthenticationService } from './../auth/authentication.service';
import {
  BaseRequestOptions,
  Http,
  Response,
  ResponseOptions
} from '@angular/http';
import {
  async,
  inject,
  TestBed
} from '@angular/core/testing';
import { MockBackend } from '@angular/http/testing';
import { IterationService } from './iteration.service';

describe ('Iteration service - ', () => {
  let apiService: IterationService;
  let mockService: MockBackend;

  let fakeAuthService: any;

  beforeEach(() => {
    fakeAuthService = {
      getToken: function () {
        return '';
      },
      isLoggedIn: function() {
        return true;
      }
    };

    TestBed.configureTestingModule({
      providers: [
        Logger,
        BaseRequestOptions,
        MockBackend,
        {
          provide: Http,
          useFactory: (backend: MockBackend,
                       options: BaseRequestOptions) => new Http(backend, options),
          deps: [MockBackend, BaseRequestOptions]
        },
        {
          provide: AuthenticationService,
          useValue: fakeAuthService
        },
        IterationService
      ]
    });
  });

  beforeEach(inject(
    [IterationService, MockBackend],
    (service: IterationService, mock: MockBackend) => {
      apiService = service;
      mockService = mock;
    }
  ));

  let resp: IterationModel[] = [{
      attributes: {
        endAt: '2016-11-29T23:18:14Z',
        name: 'Sprint #24',
        startAt: '2016-11-29T23:18:14Z',
        state: 'start'
      },
      id: 'd8535583-dfbd-4b62-be8d-44a7d4fa7048',
      links: {
        self: 'http://localhost:8080/api/iterations/d8535583-dfbd-4b62-be8d-44a7d4fa7048'
      },
      relationships: {
        space: {
          data: {
            id: 'd7d98b45-415a-4cfc-add2-ec7b7aee7dd5',
            type: 'spaces'
          },
          links: {
            self: 'http://localhost:8080/api/spaces/d7d98b45-415a-4cfc-add2-ec7b7aee7dd5'
          }
        }
      },
      type: 'iterations'
  }];
  let response = {data: resp, links: {}};
  let checkResp = cloneDeep(resp);

  it('Get iterations', async(() => {
    mockService.connections.subscribe((connection: any) => {
      connection.mockRespond(new Response(
        new ResponseOptions({
          body: JSON.stringify(response),
{'fraction_non_alphanumeric': 0.13337344564781387, 'fraction_numerical': 0.04292017649418371, 'mean_word_length': 2.293923381770145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3510960', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1554, 'n_words': 288}