import { DateAdapter } from './data.adapter';
import { CalendarItemsFilterPipe } from '../../../pipes';

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

  beforeEach(() => {
    pipe = new CalendarItemsFilterPipe(new DateAdapter());
  });

  it('should return all CalendarItems which equals the input date', () => {
    const items: any[] = [
      {
        color: 'red',
        date: new Date(2020, 5, 20),
        title: 'test1',
      },
      {
        color: 'red',
        date: new Date(2020, 5, 12),
        title: 'test2',
      },
      {
        color: 'red',
        date: ('2020-06-19T22:00:00.000Z' as unknown) as Date,
        title: 'test3',
      },
      {
        color: 'red',
        date: new Date(2020, 5, 23),
        title: 'test4',
      },
      {
        color: 'red',
        date: new Date(2020, 5, 11),
        title: 'test5',
      },
    ];

    const filteredItems = pipe.transform(items, new Date(2020, 5, 20));

    expect(filteredItems.length).toEqual(2);

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