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

import {RunScriptAssistantComponent} from "../run-script-assistant.component";
import {DeployImageComponent} from "../../deploy-image/deploy-image.component";
import {LoadingComponent} from "../../../../../../shared/loading/loading.component";
import {FormBuilder, FormsModule, ReactiveFormsModule} from "@angular/forms";
import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
import {MatFormFieldModule} from "@angular/material/form-field";
import {MatInputModule} from "@angular/material/input";
import {MatCheckboxModule} from "@angular/material/checkbox";
import {MatExpansionModule} from "@angular/material/expansion";
import {MatButtonModule} from "@angular/material/button";
import {MatTableModule} from "@angular/material/table";
import {MatDividerModule} from "@angular/material/divider";
import {MatRadioModule} from "@angular/material/radio";
import {MatProgressSpinnerModule} from "@angular/material/progress-spinner";
import {MatSelectModule} from "@angular/material/select";
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import {MatIconModule} from "@angular/material/icon";
import {ToastrModule, ToastrService} from "ngx-toastr";
import {HttpClientTestingModule, provideHttpClientTesting} from "@angular/common/http/testing";
import {TranslateLoader, TranslateModule} from "@ngx-translate/core";
import {HttpClient, provideHttpClient} from "@angular/common/http";
import {provideRouter} from "@angular/router";
import {ConfigService} from "@services/config.service";
import {HttpLoaderFactory} from "../run-script-assistant.component.spec";
import {SaveScriptComponent} from "./save-script.component";

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

  beforeEach(async () => {
    const mockConfigService = {
      apiUrl: 'http://mock-api-url',
      mercureUrl: 'http://mock-mercure-url'
    };

    await TestBed.configureTestingModule({
      declarations: [RunScriptAssistantComponent, DeployImageComponent, LoadingComponent],
      imports: [
        ReactiveFormsModule,
        FormsModule,
        MatDialogModule,
        MatFormFieldModule,
        MatInputModule,
        MatCheckboxModule,
        MatExpansionModule,
        MatButtonModule,
        MatTableModule,
        MatDividerModule,
        MatRadioModule,
        MatProgressSpinnerModule,
        MatSelectModule,
        BrowserAnimationsModule,
        MatIconModule,
        ToastrModule.forRoot(),
        HttpClientTestingModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: HttpLoaderFactory,
            deps: [HttpClient]
          }
        })
      ],
      providers: [
        FormBuilder,
        ToastrService,
        provideHttpClient(),
        provideHttpClientTesting(),
        provideRouter([]),
        {
          provide: MatDialogRef,
          useValue: {}
        },
        {
          provide: MAT_DIALOG_DATA,
          useValue: {}
        },
        { provide: ConfigService, useValue: mockConfigService }
      ]
    })
      .compileComponents();

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

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