import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { RouterTestingHarness } from '@angular/router/testing';
import { of } from 'rxjs';

import { InputDataUploadLogDetailComponent } from './input-data-upload-log-detail.component';

describe('InputDataUploadLog Management Detail Component', () => {
  let comp: InputDataUploadLogDetailComponent;
  let fixture: ComponentFixture<InputDataUploadLogDetailComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [InputDataUploadLogDetailComponent],
      providers: [
        provideRouter(
          [
            {
              path: '**',
              component: InputDataUploadLogDetailComponent,
              resolve: { inputDataUploadLog: () => of({ id: 123 }) },
            },
          ],
          withComponentInputBinding(),
        ),
      ],
    })
      .overrideTemplate(InputDataUploadLogDetailComponent, '')
      .compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(InputDataUploadLogDetailComponent);
    comp = fixture.componentInstance;
  });

  describe('OnInit', () => {
    it('Should load inputDataUploadLog on init', async () => {
      const harness = await RouterTestingHarness.create();
      const instance = await harness.navigateByUrl('/', InputDataUploadLogDetailComponent);

      // THEN
      expect(instance.inputDataUploadLog()).toEqual(expect.objectContaining({ id: 123 }));
    });
  });

  describe('PreviousState', () => {
    it('Should navigate to previous state', () => {
      jest.spyOn(window.history, 'back');
      comp.previousState();
      expect(window.history.back).toHaveBeenCalled();
    });
  });
});
