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

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

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

  beforeEach(() => {
    pipe = new HistoryDtoToStatusTextPipe();
    spyOnProperty(mapping, 'historyDtoToStatusText').and.returnValue(historyDtoToStatusTextSpy);
    historyDtoToStatusTextSpy.and.returnValue(fakeReturnValue);
  });

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

    expect(mapping.historyDtoToStatusText).toHaveBeenCalledWith(mockHistory);
    expect(result).toEqual(fakeReturnValue);
  });
});
