<commit_before>jest.dontMock('../../utils/StringUtil');
jest.dontMock('../../utils/Util');

let Framework = require('../Framework');
let ServicesList = require('../ServicesList');

describe('ServicesList', function () {

  describe('#constructor', function () {

    it('creates instances of Framework', function () {
      let items = [{foo: 'bar'}];
      let list = new ServicesList({items});
      items = list.getItems();
      expect(items[0] instanceof Framework).toBeTruthy();
    });

  });

  describe('#filter', function () {

    it('returns unfiltered list', function () {
      let items = [{a: 1}, {b: 2}];
      let list = new ServicesList({items});
      expect(list.filter().getItems().length).toEqual(2);
    });

    it('filters by ids', function () {
      let items = [
        {id: 1, name: 'marathon'},
        {id: 2, name: 'chronos'},
        {id: '3', name: 'marathon-user'}
      ];
      let list = new ServicesList({items});
      let filteredList = list.filter({ids: [2, '3']}).getItems();
      expect(filteredList.length).toEqual(2);
      expect(filteredList[0].get('name')).toEqual('chronos');
      expect(filteredList[1].get('name')).toEqual('marathon-user');
    });

    it('filters by name', function () {
      let items = [
        {name: 'marathon'},
        {name: 'chronos'},
        {name: 'marathon-user'}
      ];
      let list = new ServicesList({items});
      let filteredList = list.filter({name: 'marath'}).getItems();
      expect(filteredList.length).toEqual(2);
      expect(filteredList[0].get('name')).toEqual('marathon');
      expect(filteredList[1].get('name')).toEqual('marathon-user');
    });

    it('filters by health', function () {
      let items = [
        {name: 'marathon', getHealth: function () {return {value: 1}; }},
        {name: 'chronos', getHealth: function () {return {value: 0}; }},
        {name: 'marathon-user', getHealth: function () {return {value: 2}; }}
      ];

      let list = new ServicesList({items});
      let filteredList = list.filter({health: [0]}).getItems();
      expect(filteredList.length).toEqual(1);
      expect(filteredList[0].get('name')).toEqual('chronos');
    });

    it('filters by status', function () {
      let items = [
        {name: 'marathon', getStatus: function () {return {value: 1}; }},
        {name: 'chronos', getStatus: function () {return {value: 0}; }},
        {name: 'marathon-user', getStatus: function () {return {value: 2}; }}
      ];

      let list = new ServicesList({items});
      let filteredList = list.filter({status: [0]}).getItems();<commit_msg>Fix failing tests<commit_after>jest.dontMock('../../utils/StringUtil');
jest.dontMock('../../utils/Util');

let Framework = require('../Framework');
let ServicesList = require('../ServicesList');

describe('ServicesList', function () {

  describe('#constructor', function () {

    it('creates instances of Framework', function () {
      let items = [{foo: 'bar'}];
      let list = new ServicesList({items});
      items = list.getItems();
      expect(items[0] instanceof Framework).toBeTruthy();
    });

  });

  describe('#filter', function () {

    it('returns unfiltered list', function () {
      let items = [{a: 1}, {b: 2}];
      let list = new ServicesList({items});
      expect(list.filter().getItems().length).toEqual(2);
    });

    it('filters by ids', function () {
      let items = [
        {id: 1, name: 'marathon'},
        {id: 2, name: 'chronos'},
        {id: '3', name: 'marathon-user'}
      ];
      let list = new ServicesList({items});
      let filteredList = list.filter({ids: [2, '3']}).getItems();
      expect(filteredList.length).toEqual(2);
      expect(filteredList[0].get('name')).toEqual('chronos');
      expect(filteredList[1].get('name')).toEqual('marathon-user');
    });

    it('filters by name', function () {
      let items = [
        {name: 'marathon'},
        {name: 'chronos'},
        {name: 'marathon-user'}
      ];
      let list = new ServicesList({items});
      let filteredList = list.filter({name: 'marath'}).getItems();
      expect(filteredList.length).toEqual(2);
      expect(filteredList[0].get('name')).toEqual('marathon');
      expect(filteredList[1].get('name')).toEqual('marathon-user');
    });

    it('filters by health', function () {
      let items = [
        {name: 'marathon', getHealth: function () {return {value: 1}; }},
        {name: 'chronos', getHealth: function () {return {value: 0}; }},
        {name: 'marathon-user', getHealth: function () {return {value: 2}; }}
      ];

      let list = new ServicesList({items});
      let filteredList = list.filter({health: [0]}).getItems();
      expect(filteredList.length).toEqual(1);
      expect(filteredList[0].get('name')).toEqual('chronos');
    });

    it('filters by status', function () {
      let items = [
        {name: 'marathon', getServiceStatus: function () {return {key: 0}; }},
        {name: 'chronos', getServiceStatus: function () {return {key: 1}; }},
        {name: 'marathon-user', getServiceStatus: function () {return {key: 2}; }}
      ];

      let list = new ServicesList({items});
      let filteredList = list.filter({status: [1]}).getItems();
{'fraction_non_alphanumeric': 0.19988490312679838, 'fraction_numerical': 0.00959140610013428, 'mean_word_length': 3.0830070477682066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2226544', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1561, 'n_words': 345}