import { CalendarItemsFilterUniqueStatusTypePipe } from './calendar-items-filter-unique-status.pipe';

describe('CalendarItemsFilterUniqueStatusType', () => {
  let pipe: CalendarItemsFilterUniqueStatusTypePipe;

  beforeEach(() => {
    pipe = new CalendarItemsFilterUniqueStatusTypePipe();
  });

  it('should provide only one CalendarItem per color / status', () => {
    const items: any[] = [
      {
        color: 'red',
        date: new Date(2020, 5, 20),
        title: 'test1',
      },
      {
        color: 'red',
        date: new Date(2020, 5, 12),
        title: 'test2',
      },
      {
        color: 'green',
        date: ('2020-06-19T22:00:00.000Z' as unknown) as Date,
        title: 'test3',
      },
      {
        color: 'green',
        date: new Date(2020, 5, 23),
        title: 'test4',
      },
      {
        color: 'red',
        date: new Date(2020, 5, 11),
        title: 'test5',
      },
    ];

    const uniqueCalendarItemsPerColor = pipe.transform(items);
    expect(uniqueCalendarItemsPerColor.length).toBe(2);

    expect(uniqueCalendarItemsPerColor[0].title).toBe('test1');
    expect(uniqueCalendarItemsPerColor[1].title).toBe('test3');
  });
});
