/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { TestBed } from '@angular/core/testing';
import { Category } from '../models/category';
import { CategoryService } from './category.service';
import { PinboardI18nService } from './pinboard-i18n.service';

describe('CategoryService', () => {
  let service: CategoryService;
  let cat2: Category;

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [CategoryService, PinboardI18nService],
    });

    service = TestBed.inject(CategoryService);
    const cat1 = {} as Category;
    cat2 = {} as Category;
    cat1.id = 'catId1';
    cat2.id = 'catId2';
    service.addCategory(cat2);
    service.addCategory(cat1);
  });

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

  it('#getCategories should return Category array', () => {
    const res = service.getCategories();
    expect(res).toBeDefined();
  });

  it('#getCategory should return a single Category', () => {
    expect(service.getCategory('catId2')).toBe(cat2);
  });

  it('#addCategory should add a Category', () => {
    const cat3 = {} as Category;
    cat3.id = 'catId3';
    service.addCategory(cat3);
    expect(service.getCategory('catId3')).toBe(cat3);
  });
});
