import { historiesDtoMock } from '../../../shared/mockdata';
import { FilterHistoriesWithStatusChangePipe } from './filter-histories-with-status-change.pipe';
import { HistoryDTO } from '@cmf/trade-api';

fdescribe('Pipe: HistoryDtoToInfoTextPipe', () => {
  let pipe: FilterHistoriesWithStatusChangePipe;

  const mockHistories: HistoryDTO[] = historiesDtoMock;

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

  it('should only return histories with a status change', () => {
    const result = pipe.transform(mockHistories);

    expect(result.length).toBe(2);
    expect(result).toEqual([
      {
        location: 'München Neuhausen',
        id: 114392259,
        version: 2,
        changed: '2020-02-24T14:53:58.9359',
        changedBy: 'Lorenz Hilpert',
        changeset: 68359312,
        historyset: 10896418,
        values: [
          {
            caption: 'Eingetroffen/Versendet',
            value: '',
            previousValue: '02.07.2020 10:55:23',
          },
          {
            caption: 'Status',
            value: 'bestellt',
            previousValue: 'eingetroffen',
          },
          {
            caption: 'Status Datum',
            value: '24.02.2020 14:53:58',
            previousValue: '02.07.2020 10:55:23',
          },
          { caption: 'Abholfach-Nr', value: '', previousValue: '130_0207_1' },
          {
            caption: 'Im Abholfach seit',
            value: '',
            previousValue: '02.07.2020 10:55:23',
          },
          {
            caption: 'Im Abholfach bis',
            value: '',
            previousValue: '16.07.2020 10:55:23',
          },
        ],
      },
      {
        location: 'München Neuhausen',
        id: 114392259,
        version: 1,
        changed: '2020-02-24T14:53:57.6544',
        changedBy: 'Lorenz Hilpert',
        changeset: 68359310,
        historyset: 9520697,
        values: [
          { caption: 'Meldenummer', value: '', previousValue: '999' },
          {
            caption: 'bestellt bei Lieferant am',
            value: '',
            previousValue: '24.02.2020 14:53:58',
          },
          {
            caption: 'vsl. Lieferdatum',
            value: '25.02.2020 15:00:00',
            previousValue: '25.02.2020 14:00:00',
          },
          { caption: 'Status', value: 'neu', previousValue: 'bestellt' },
          {
            caption: 'Status Datum',
            value: '24.02.2020 14:53:57',
            previousValue: '24.02.2020 14:53:58',
          },
        ],
      },
    ]);
  });
});
