<commit_before>import { NodeListService } from './node-list.service';
import {
  async,
  getTestBed,
  TestBed
} from '@angular/core/testing';

describe('NodeListService', () => {
  let service;

  beforeEach(() => {
    service = new NodeListService();
  });

  it('converts empty nodeList to an empty array', () => expect(service.toArray({length: 0})).toEqual([]));
  it('converts nodeList with children to populated array', () => expect(service.toArray({length: 2, 0: 0, 1: 1})).toEqual([0, 1]));
});<commit_msg>Refined test a bit more<commit_after>import { NodeListService } from './node-list.service';

describe('NodeListService', () => {
  let service;

  beforeEach(() => {
    service = new NodeListService();
  });

  it('converts empty nodeList to an empty array', () => expect(service.toArray(mockNodeList([]))).toEqual([]));
  it('converts nodeList with children to populated array', () => expect(service.toArray(mockNodeList([0, 1]))).toEqual([0, 1]));
});

function mockNodeList(list: any[]) {
  const mockedList = { length: list.length };
  list.forEach((item, index) => mockedList[index] = item);
  return mockedList;
}
{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.01056338028169014, 'mean_word_length': 5.015873015873016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '366099', 'n_tokens_mistral': 368, 'n_tokens_neox': 351, 'n_words': 86}