<commit_before>import { TestBed } from '@angular/core/testing';

import { EnvironmentService, PolygonUpperBoundYPosition, TimestampUpperBoundSet } from './environment';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CandidateInfo } from '../models/Data';

describe('EnvironmentService', () => {
  let service: EnvironmentService;

  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule]
    });
    service = TestBed.inject(EnvironmentService);
  });

  // TODO(naoai): write getPolygons test

  it('#computeNextSnapshot insert new candidate', () => {
    const inputCandInfo: CandidateInfo[] = [{name: '1', job_count: 100}, {name: '2', job_count: 100}];
    const inputSet: TimestampUpperBoundSet = new TimestampUpperBoundSet();
    inputSet.orderMap.set('1', 0);
    inputSet.snapshot[0] = new PolygonUpperBoundYPosition('1', 100);

    // @ts-ignore
    const result: [TimestampUpperBoundSet, number] = service.computeNextSnapshot(inputCandInfo, inputSet);

    expect(result[0].snapshot[0].position).toEqual(50);
    expect(result[0].snapshot[1].position).toEqual(100);
    expect(result[1]).toEqual(1);
  });

  it('#computeNextSnapshot candidateInfo[] empty', () => {
    const emptyCandInfo: CandidateInfo[] = [];
    const inputSet: TimestampUpperBoundSet = new TimestampUpperBoundSet();
    inputSet.orderMap.set('1', 0);
    inputSet.snapshot[0] = new PolygonUpperBoundYPosition('1', 100);

    // @ts-ignore
    const result: [TimestampUpperBoundSet, number] = service.computeNextSnapshot(emptyCandInfo, inputSet);

    expect(result[0]).toBe(inputSet);
  });

  it('#computeNextSnapshot with empty set', () => {
    const inputCandInfo: CandidateInfo[] = [{name:  '1', job_count: 105}, {name: '2', job_count: 300},
      {name: '3', job_count: 595}];
    const emptySet: TimestampUpperBoundSet = new TimestampUpperBoundSet();
<commit_msg>Rename tests.<commit_after>import { TestBed } from '@angular/core/testing';

import { EnvironmentService, PolygonUpperBoundYPosition, TimestampUpperBoundSet } from './environment';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CandidateInfo } from '../models/Data';

describe('EnvironmentService', () => {
  let service: EnvironmentService;

  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule]
    });
    service = TestBed.inject(EnvironmentService);
  });

  // TODO(naoai): write getPolygons test

  it('#computeNextSnapshot inserts new candidate', () => {
    const inputCandInfo: CandidateInfo[] = [{name: '1', job_count: 100}, {name: '2', job_count: 100}];
    const inputSet: TimestampUpperBoundSet = new TimestampUpperBoundSet();
    inputSet.orderMap.set('1', 0);
    inputSet.snapshot[0] = new PolygonUpperBoundYPosition('1', 100);

    // @ts-ignore
    const result: [TimestampUpperBoundSet, number] = service.computeNextSnapshot(inputCandInfo, inputSet);

    expect(result[0].snapshot[0].position).toEqual(50);
    expect(result[0].snapshot[1].position).toEqual(100);
    expect(result[1]).toEqual(1);
  });

  it('#computeNextSnapshot candidate info list is empty', () => {
    const emptyCandInfo: CandidateInfo[] = [];
    const inputSet: TimestampUpperBoundSet = new TimestampUpperBoundSet();
    inputSet.orderMap.set('1', 0);
    inputSet.snapshot[0] = new PolygonUpperBoundYPosition('1', 100);

    // @ts-ignore
    const result: [TimestampUpperBoundSet, number] = service.computeNextSnapshot(emptyCandInfo, inputSet);

    expect(result[0]).toBe(inputSet);
  });

  it('#computeNextSnapshot with old TimestampUpperBoundSet empty', () => {
    const inputCandInfo: CandidateInfo[] = [{name:  '1', job_count: 105}, {name: '2', job_count: 300},
      {name: '3', job_count: 595}];
    const emptySet: TimestampUpperBoundSet = new TimestampUpperBoundSet();

{'fraction_non_alphanumeric': 0.15057915057915058, 'fraction_numerical': 0.023680823680823682, 'mean_word_length': 4.987673343605547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3430740', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1150, 'n_words': 239}