import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { PageWhrTestComponent } from './page-ytb.component';

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

  beforeEach(waitForAsync(() => {
    TestBed.configureTestingModule({
      imports: [PageWhrTestComponent],
    }).compileComponents();

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

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

  it('should calculate waist-to-hip ratio correctly', () => {
    component.height = 170;
    component.waist = 70;
    component.hip = 90;
    component.calculateWhr();
    expect(component.whr).toBeCloseTo(0.777, 2);
  });

  it('should show alert if input is invalid', async () => {
    component.height = null;
    component.waist = 0;
    component.hip = 90;
    await component.calculateWhr();
    expect(component.whr).toBeNull();
  });
});
