<commit_before>import { ComponentFixture, TestBed, async } from "@angular/core/testing";
import { User } from "./user";
import { UserListComponent } from "./user-list.component";
import { UserListService } from "./user-list.service";
import { Observable } from "rxjs";
//import { PipeModule } from "../../pipe.module";

describe("User list", () => {

  let userList: UserListComponent;
  let fixture: ComponentFixture<UserListComponent>;

  let userListServiceStub: {
    getUsers: () => Observable<User[]>
  };

  beforeEach(() => {
    // stub UserService for test purposes
    userListServiceStub = {
      getUsers: () => Observable.of([
        {
          id: "chris_id",
          name: "Chris",
          age: 25,
          company: "UMM",
          email: "<EMAIL>"
        },
        {
          id: "pat_id",
          name: "Pat",
          age: 37,
          company: "IBM",
          email: "<EMAIL>"
        },
        {
          id: "jamie_id",
          name: "Jamie",
          age: 37,
          company: "Frogs, Inc.",
          email: "<EMAIL>"
        }
      ])
    };

    TestBed.configureTestingModule({
      //imports: [PipeModule],
      declarations: [ UserListComponent ],
      // providers:    [ UserListService ]  // NO! Don't provide the real service!
      // Provide a test-double instead
      providers:    [ { provide: UserListService, useValue: userListServiceStub } ]
    })
  });

  beforeEach(async(() => {
    TestBed.compileComponents().then(() => {
      fixture = TestBed.createComponent(UserListComponent);
      userList = fixture.componentInstance;
      fixture.detectChanges();
    });
  }));

  it("contains all the users", () => {
    expect(userList.users.length).toBe(3);
  });

  it("contains a user named 'Chris'", () => {
    expect(userList.users.some((user: User) => user.name === "Chris" )).toBe(true);
  });

  it("contain a user named 'Jamie'", () => {
    expect(userList.users.some((user: User) => user.name === "Jamie" )).toBe(true);
  });

  it("doesn't contain a user named 'Santa'", () => {
    expect(userList.users.some((user: User) => user.name === "Santa" )).toBe(false);
  });

  it("has two users that are 37 years old", () => {
    expect(userList.users.filter((user: User) => user.age === 37).length).toBe(2);
  });

});

describe("User list", () => {
  let userList: UserListComponent;
  let fixture: ComponentFixture<UserListComponent>;

  let userListServiceStub: {
    getUsers: () => Observable<User[]>
  };

  beforeEach(() => {
    // stub UserService for test purposes
    userListServiceStub = {
      getUsers: () => Observable.create(observer => {
        observer.error("Error-prone observable");
      })
    };

    TestBed.configureTestingModule({
      declarations: [ UserListComponent ],
      providers:    [ { provide: UserListService, useValue: userListServiceStub } ]
    })
  });

  beforeEach(async(() => {
    TestBed.compileComponents().then(() => {
      fixture = TestBed.createComponent(UserListComponent);
      userList = fixture.componentInstance;
      fixture.detectChanges();<commit_msg>Improve name of test description<commit_after>import { ComponentFixture, TestBed, async } from "@angular/core/testing";
import { User } from "./user";
import { UserListComponent } from "./user-list.component";
import { UserListService } from "./user-list.service";
import { Observable } from "rxjs";
//import { PipeModule } from "../../pipe.module";

describe("User list", () => {

  let userList: UserListComponent;
  let fixture: ComponentFixture<UserListComponent>;

  let userListServiceStub: {
    getUsers: () => Observable<User[]>
  };

  beforeEach(() => {
    // stub UserService for test purposes
    userListServiceStub = {
      getUsers: () => Observable.of([
        {
          id: "chris_id",
          name: "Chris",
          age: 25,
          company: "UMM",
          email: "<EMAIL>"
        },
        {
          id: "pat_id",
          name: "Pat",
          age: 37,
          company: "IBM",
          email: "<EMAIL>"
        },
        {
          id: "jamie_id",
          name: "Jamie",
          age: 37,
          company: "Frogs, Inc.",
          email: "<EMAIL>"
        }
      ])
    };

    TestBed.configureTestingModule({
      //imports: [PipeModule],
      declarations: [ UserListComponent ],
      // providers:    [ UserListService ]  // NO! Don't provide the real service!
      // Provide a test-double instead
      providers:    [ { provide: UserListService, useValue: userListServiceStub } ]
    })
  });

  beforeEach(async(() => {
    TestBed.compileComponents().then(() => {
      fixture = TestBed.createComponent(UserListComponent);
      userList = fixture.componentInstance;
      fixture.detectChanges();
    });
  }));

  it("contains all the users", () => {
    expect(userList.users.length).toBe(3);
  });

  it("contains a user named 'Chris'", () => {
    expect(userList.users.some((user: User) => user.name === "Chris" )).toBe(true);
  });

  it("contain a user named 'Jamie'", () => {
    expect(userList.users.some((user: User) => user.name === "Jamie" )).toBe(true);
  });

  it("doesn't contain a user named 'Santa'", () => {
    expect(userList.users.some((user: User) => user.name === "Santa" )).toBe(false);
  });

  it("has two users that are 37 years old", () => {
    expect(userList.users.filter((user: User) => user.age === 37).length).toBe(2);
  });

});

describe("Misbehaving User List", () => {
  let userList: UserListComponent;
  let fixture: ComponentFixture<UserListComponent>;

  let userListServiceStub: {
    getUsers: () => Observable<User[]>
  };

  beforeEach(() => {
    // stub UserService for test purposes
    userListServiceStub = {
      getUsers: () => Observable.create(observer => {
        observer.error("Error-prone observable");
      })
    };

    TestBed.configureTestingModule({
      declarations: [ UserListComponent ],
      providers:    [ { provide: UserListService, useValue: userListServiceStub } ]
    })
  });

  beforeEach(async(() => {
    TestBed.compileComponents().then(() => {
      fixture = TestBed.createComponent(UserListComponent);
      userList = fixture.componentInstance;
      fixture.detectChanges();
{'fraction_non_alphanumeric': 0.166158781074579, 'fraction_numerical': 0.0038492381716118684, 'mean_word_length': 2.6812278630460447, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 61, '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': '3010819', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1863, 'n_words': 390}