import * as mappings from '../mappings';
import { HistoryDtoToInfoTextPipe } from './historyDtoToinfoText.pipe';
import { HistoryDTO } from '@cmf/trade-api';
import { historyDtoMock } from '../../../shared/mockdata';

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

  const mockHistory: HistoryDTO = historyDtoMock;
  const fakeReturnValue = 'mapped result';
  const historyDtoToInfoTextSpy: jasmine.Spy = jasmine.createSpy('historyDtoToInfoTextSpy');

  beforeEach(() => {
    pipe = new HistoryDtoToInfoTextPipe();
    spyOnProperty(mappings, 'historyDtoToInfoText', 'get').and.returnValue(historyDtoToInfoTextSpy);
    historyDtoToInfoTextSpy.and.returnValue(fakeReturnValue);
  });

  it('should call historyDtoToInfoText and return its mapped value', () => {
    const result = pipe.transform(mockHistory);

    expect(mappings.historyDtoToInfoText).toHaveBeenCalledWith(mockHistory);
    expect(result).toEqual(fakeReturnValue);
  });
});
