import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UserAvatarFormComponent } from './user-avatar-form.component';
import { provideRouter } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { AuthService } from '@app/core/services/authentication/auth.service';
import { UserRepository } from '@app/domain/users/user.repository';
import { USER_REPOSITORY_TOKEN } from '@app/infrastructure/users/user-repository.token';

describe('UserAvatarFormComponent', () => {
  let component: UserAvatarFormComponent;
  let fixture: ComponentFixture<UserAvatarFormComponent>;

  let mockToastrService: Partial<ToastrService>;
  let mockAuthService: Partial<AuthService>;
  let mockUserRepo: UserRepository;

  beforeEach(async () => {
    mockToastrService = {
      warning: jest.fn(),
      success: jest.fn(),
      error: jest.fn(),
    };

    mockAuthService = {
      updateUser: jest.fn(),
    };

    mockUserRepo = {
      update: jest.fn(),
      getUserById: jest.fn(),
    };

    await TestBed.configureTestingModule({
      imports: [UserAvatarFormComponent],
      providers: [
        provideRouter([]),
        { provide: USER_REPOSITORY_TOKEN, useValue: mockUserRepo },
        { provide: ToastrService, useValue: mockToastrService },
        { provide: AuthService, useValue: mockAuthService },
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(UserAvatarFormComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});
