import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageStory } from './page-story';

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

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [PageStory]
    }).compileComponents();
    
    fixture = TestBed.createComponent(PageStory);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

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

  it('should open story modal', () => {
    const storyId = 1;
    component.openStoryModal(storyId);
    expect(component.isModalOpen()).toBeTrue();
    expect(component.selectedStoryId()).toBe(storyId);
  });

  it('should close modal', () => {
    component.openStoryModal(1);
    component.closeModal();
    expect(component.isModalOpen()).toBeFalse();
  });

  it('should set active category', () => {
    const categoryId = 2;
    component.setActiveCategory(categoryId);
    const activeCategory = component.categories.find(c => c.active);
    expect(activeCategory?.id).toBe(categoryId);
  });
});