import { describe, it, expect } from 'vitest';
import { DeleteMediaViewModel } from './DeleteMediaViewModel';

describe('DeleteMediaViewModel', () => {
  it('should create instance with success true', () => {
    const dto = { success: true };
    const viewModel = new DeleteMediaViewModel(dto);

    expect(viewModel.success).toBe(true);
    expect(viewModel.error).toBeUndefined();
  });

  it('should create instance with success false and error', () => {
    const dto = { success: false, error: 'Failed to delete media' };
    const viewModel = new DeleteMediaViewModel(dto);

    expect(viewModel.success).toBe(false);
    expect(viewModel.error).toBe('Failed to delete media');
  });

  it('should return true for isSuccessful when success is true', () => {
    const viewModel = new DeleteMediaViewModel({ success: true });

    expect(viewModel.isSuccessful).toBe(true);
  });

  it('should return false for isSuccessful when success is false', () => {
    const viewModel = new DeleteMediaViewModel({ success: false });

    expect(viewModel.isSuccessful).toBe(false);
  });

  it('should return false for hasError when no error', () => {
    const viewModel = new DeleteMediaViewModel({ success: true });

    expect(viewModel.hasError).toBe(false);
  });

  it('should return true for hasError when error exists', () => {
    const viewModel = new DeleteMediaViewModel({
      success: false,
      error: 'Something went wrong',
    });

    expect(viewModel.hasError).toBe(true);
  });

  it('should handle empty error string as falsy', () => {
    const viewModel = new DeleteMediaViewModel({
      success: false,
      error: '',
    });

    expect(viewModel.hasError).toBe(false);
  });
});