import { describe, it, expect } from 'vitest'; import { TestBed } from '@angular/core/testing'; import { provideZonelessChangeDetection } from '@angular/core'; import { App } from './app'; import { appConfig } from './app.config'; describe('Custom Form Controls', () => { it('renders the initial contract and handles the documented operations', async () => { TestBed.configureTestingModule({ imports: [App], providers: [...(appConfig.providers ?? [])], }); const fixture = TestBed.createComponent(App); const element = fixture.nativeElement as HTMLElement; fixture.detectChanges(); await fixture.whenStable(); const text = () => element.querySelector('[data-result]')?.textContent?.trim(); expect(text()).toBe('2 selected'); element.querySelector('quantity-control button')!.click(); fixture.detectChanges(); await fixture.whenStable(); expect(text()).toBe('3 selected'); element.querySelector('[data-disable]')!.click(); fixture.detectChanges(); await fixture.whenStable(); expect(text()).toBe('3 selected'); expect( element.querySelector('quantity-control button')!.disabled, ).toBe(true); fixture.destroy(); }); });