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

import { AutocompleteService } from './autocomplete.service';

// TODO

let autocompleteService: AutocompleteService;

describe('AutocompleteService', () => {

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [AutocompleteService]
    });
    autocompleteService = TestBed.inject(AutocompleteService);
  });

  it('should be created', () => {
    expect(autocompleteService).toBeTruthy();
  });

  it('should should return a bind function', () => {
    expect(autocompleteService.bind('a', ['b'])).toBeTruthy();
  });

  it('should return search results', () => {
    autocompleteService.search(['aa', 'ab', 'bb'], 'a').subscribe(res => {
      expect(res).toEqual(['aa', 'ab']);
    });
  });

  it('should return an empty array if no result was found', () => {
    autocompleteService.search(['aa', 'ab', 'bb'], 'c').subscribe(res => {
      expect(res).toEqual([]);
    });
  });
});
