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

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

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

  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: [UserFormComponent],
      providers: [
        provideRouter([]),
        FormBuilder,
        { provide: USER_REPOSITORY_TOKEN, useValue: mockUserRepo },
        { provide: ToastrService, useValue: mockToastrService },
        { provide: AuthService, useValue: mockAuthService },
      ],
    }).compileComponents();

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

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