{"size": 1576, "ext": "js", "max_stars_repo_path": "__test__/filterCustomer.spec.js", "max_stars_repo_name": "mcabreradev/filter", "max_stars_repo_stars_event_min_datetime": "2019-11-17T08:32:08.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:31:10.000Z", "max_issues_repo_path": "__test__/filterCustomer.spec.js", "max_issues_repo_name": "mcabreradev/filter", "max_issues_repo_issues_event_min_datetime": "2020-07-08T21:49:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-21T02:02:23.000Z", "max_forks_repo_path": "__test__/filterCustomer.spec.js", "max_forks_repo_name": "mcabreradev/filter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 27.1724137931, "max_line_length": 70, "alphanum_fraction": 0.5596446701}
'use strict';

const filter = require('../index');
const customers = require('../data.json');

describe("Filter function", () => {

  test('it should filter single string', () => {
    let output = filter(customers, 'Berlin');
    let input = [
      { name: 'Alfreds Futterkiste', city: 'Berlin' }
    ];

    expect(input).toEqual(output);
  });

  test('it should filter city', () => {
    let output = filter(customers, {'city' : 'Mars'});
    let input = [
      { name: 'Bon app', city: 'Marseille' }
    ];

    expect(input).toEqual(output);
  });

  test('it should filter city with single character', () => {
    let output = filter(customers, {'city' : 's'});
    let input = [
      { name: 'Bon app', city: 'Marseille' },
      { name: 'Bottom-Dollar Marketse', city: 'Tsawassen' },
      { name: 'Cactus Comidas para llevar', city: 'Buenos Aires' }
    ];

    expect(input).toEqual(output);
  });

  test('it should filter city and name with single character', () => {
    let output = filter(customers, {'name' : 'O', 'city' : 'London'});
    let input = [
      { name: 'Around the Horn', city: 'London' }
    ];

    expect(input).toEqual(output);
  });

  test('it should filter input with two single letters', () => {
    let output = filter(customers, {'city' : 'B', 'city' : 'L'});
    let input = [
      { name: 'Alfreds Futterkiste', city: 'Berlin' },
      { name: 'Around the Horn', city: 'London' },
      { name: 'B\'s Beverages', city: 'London' },
      { name: 'Bon app', city: 'Marseille' }
    ];

    expect(input).toEqual(output);
  });

});