import { DeleteMediaPresenter } from './DeleteMediaPresenter';

describe('DeleteMediaPresenter', () => {
  let presenter: DeleteMediaPresenter;

  beforeEach(() => {
    presenter = new DeleteMediaPresenter();
  });

  describe('transform', () => {
    it('should map successful result to response model', () => {
      const result = { mediaId: 'media-123', deleted: true };

      const response = presenter.transform(result);

      expect(response).toEqual({ success: true });
      expect(presenter.getResponseModel()).toEqual({ success: true });
    });

    it('should handle failed deletion', () => {
      const result = { mediaId: 'media-123', deleted: false };

      const response = presenter.transform(result);

      expect(response).toEqual({ success: false });
      expect(presenter.getResponseModel()).toEqual({ success: false });
    });
  });

  describe('reset', () => {
    it('should clear the model', () => {
      presenter.transform({ mediaId: 'media-123', deleted: true });
      expect(presenter.getResponseModel()).not.toBeNull();

      presenter.reset();
      expect(presenter.getResponseModel()).toBeNull();
    });
  });

  describe('responseModel', () => {
    it('should throw error when accessed before transform()', () => {
      expect(() => presenter.responseModel).toThrow('Presenter not presented');
    });

    it('should return model after transform()', () => {
      presenter.transform({ mediaId: 'media-123', deleted: true });
      expect(presenter.responseModel).toEqual({ success: true });
    });
  });

  describe('getResponseModel', () => {
    it('should return null before transform()', () => {
      expect(presenter.getResponseModel()).toBeNull();
    });

    it('should return model after transform()', () => {
      presenter.transform({ mediaId: 'media-123', deleted: true });
      expect(presenter.getResponseModel()).toEqual({ success: true });
    });
  });
});