import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NumberInputDialogComponent, NumberInputDialogData } from './number-input-dialog.component';
import { DialogContentDirective } from '../dialog-content.directive';
import { DialogComponent } from '../dialog.component';
import { DialogRef, DIALOG_DATA } from '@angular/cdk/dialog';

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

  beforeEach(async () => {
    const dialogMock = {
      close: jest.fn(),
      data: { message: 'Test message' },
    };

    const dialogRefMock = {
      close: jest.fn(),
    };

    await TestBed.configureTestingModule({
      imports: [NumberInputDialogComponent],
      providers: [
        { provide: DialogComponent, useValue: dialogMock },
        { provide: DialogRef, useValue: dialogRefMock },
        { provide: DIALOG_DATA, useValue: { message: 'Test message' } },
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(NumberInputDialogComponent);
    component = fixture.componentInstance;
  });

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

  it('should extend DialogContentDirective', () => {
    expect(component).toBeInstanceOf(DialogContentDirective);
  });

  it('should have correct selector', () => {
    expect(component.constructor.name).toBe('NumberInputDialogComponent');
  });

  describe('component properties', () => {
    it('should have correct selector', () => {
      expect(component.constructor.name).toBe('NumberInputDialogComponent');
    });

    it('should be a valid component', () => {
      expect(component).toBeTruthy();
      expect(component).toBeInstanceOf(NumberInputDialogComponent);
    });
  });

  describe('data interfaces', () => {
    it('should support NumberInputDialogData with all properties', () => {
      const testData: NumberInputDialogData = {
        message: 'Enter a number',
        inputLabel: 'Amount',
        inputValue: 100,
        inputDefaultValue: 0,
        inputValidation: [],
        closeText: 'Cancel',
        confirmText: 'OK',
      };

      expect(testData.message).toBe('Enter a number');
      expect(testData.inputLabel).toBe('Amount');
      expect(testData.inputValue).toBe(100);
      expect(testData.inputDefaultValue).toBe(0);
      expect(testData.inputValidation).toEqual([]);
      expect(testData.closeText).toBe('Cancel');
      expect(testData.confirmText).toBe('OK');
    });

    it('should support NumberInputDialogData with only required properties', () => {
      const testData: NumberInputDialogData = {
        message: 'Enter a number',
      };

      expect(testData.message).toBe('Enter a number');
      expect(testData.inputLabel).toBeUndefined();
      expect(testData.inputValue).toBeUndefined();
      expect(testData.inputDefaultValue).toBeUndefined();
      expect(testData.inputValidation).toBeUndefined();
      expect(testData.closeText).toBeUndefined();
      expect(testData.confirmText).toBeUndefined();
    });
  });

  describe('result interface', () => {
    it('should support NumberInputDialogResult with inputValue', () => {
      const result = { inputValue: 42 };
      expect(result.inputValue).toBe(42);
    });

    it('should support NumberInputDialogResult with undefined inputValue', () => {
      const result = { inputValue: undefined };
      expect(result.inputValue).toBeUndefined();
    });
  });
});