import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import { InfoButtonComponent } from './info-button.component';
import { NgIconComponent } from '@ng-icons/core';
import { MockComponent } from 'ng-mocks';

describe('InfoButtonComponent', () => {
  let spectator: Spectator<InfoButtonComponent>;
  const createComponent = createComponentFactory({
    component: InfoButtonComponent,
    declarations: [MockComponent(NgIconComponent)],
  });

  beforeEach(() => {
    spectator = createComponent();
  });

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

  it('should have the default "ui-info-button" class when pending is false', () => {
    spectator.setInput('pending', false);
    spectator.detectChanges();

    const hostClasses = spectator.element.classList;
    expect(hostClasses).toContain('ui-info-button');
    expect(hostClasses).not.toContain('ui-info-button--pending');
  });

  it('should add the "ui-info-button--pending" class when pending is true', () => {
    spectator.setInput('pending', true);
    spectator.detectChanges();

    const hostClasses = spectator.element.classList;
    expect(hostClasses).toContain('ui-info-button');
    expect(hostClasses).toContain('ui-info-button--pending');
  });
});
