import { describe, it, expect } from 'vitest'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { Card } from '@app/shared/ui/card/card'; describe('Card', () => { let component: Card; let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [Card], }).compileComponents(); fixture = TestBed.createComponent(Card); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should render a div with card class', () => { const div = fixture.nativeElement.querySelector('.card'); expect(div).toBeTruthy(); }); it('should not apply elevated class by default', () => { const div = fixture.nativeElement.querySelector('.card'); expect(div.classList.contains('card--elevated')).toBe(false); }); it('should apply elevated class when elevated is true', () => { fixture.componentRef.setInput('elevated', true); fixture.detectChanges(); const div = fixture.nativeElement.querySelector('.card'); expect(div.classList.contains('card--elevated')).toBe(true); }); it('should apply bordered class when bordered is true', () => { fixture.componentRef.setInput('bordered', true); fixture.detectChanges(); const div = fixture.nativeElement.querySelector('.card'); expect(div.classList.contains('card--bordered')).toBe(true); }); it('should apply inverse class when inverse is true', () => { fixture.componentRef.setInput('inverse', true); fixture.detectChanges(); const div = fixture.nativeElement.querySelector('.card'); expect(div.classList.contains('card--inverse')).toBe(true); }); it('should render content projection', () => { const hostFixture = TestBed.createComponent(Card); hostFixture.nativeElement.innerHTML = '

Test content

'; hostFixture.detectChanges(); const content = hostFixture.nativeElement.querySelector('p'); expect(content?.textContent).toBe('Test content'); }); });