@@ -40,6 +40,8 @@ import {
4040 ɵɵsetNgModuleScope as setNgModuleScope ,
4141 ɵɵtext as text ,
4242 DOCUMENT ,
43+ signal ,
44+ provideZonelessChangeDetection ,
4345} from '../src/core' ;
4446import { DeferBlockBehavior } from '../testing' ;
4547import { TestBed , TestBedImpl } from '../testing/src/test_bed' ;
@@ -50,6 +52,7 @@ import {NgModuleType} from '../src/render3';
5052import { depsTracker } from '../src/render3/deps_tracker/deps_tracker' ;
5153import { setClassMetadataAsync } from '../src/render3/metadata' ;
5254import {
55+ ComponentFixtureAutoDetect ,
5356 TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT ,
5457 THROW_ON_UNKNOWN_ELEMENTS_DEFAULT ,
5558 THROW_ON_UNKNOWN_PROPERTIES_DEFAULT ,
@@ -2273,6 +2276,58 @@ describe('TestBed', () => {
22732276
22742277 expect ( TestBed . runInInjectionContext ( functionThatUsesInject ) ) . toEqual ( expectedValue ) ;
22752278 } ) ;
2279+
2280+ describe ( 'TestBed.tick' , ( ) => {
2281+ @Component ( {
2282+ template : '{{state()}}' ,
2283+ } )
2284+ class Thing1 {
2285+ state = signal ( 1 ) ;
2286+ }
2287+
2288+ describe ( 'with zone change detection' , ( ) => {
2289+ it ( 'should update fixtures with autoDetect' , ( ) => {
2290+ TestBed . configureTestingModule ( {
2291+ providers : [ { provide : ComponentFixtureAutoDetect , useValue : true } ] ,
2292+ } ) ;
2293+ const { nativeElement, componentInstance} = TestBed . createComponent ( Thing1 ) ;
2294+ expect ( nativeElement . textContent ) . toBe ( '1' ) ;
2295+
2296+ componentInstance . state . set ( 2 ) ;
2297+ TestBed . tick ( ) ;
2298+ expect ( nativeElement . textContent ) . toBe ( '2' ) ;
2299+ } ) ;
2300+
2301+ it ( 'should update fixtures without autoDetect' , ( ) => {
2302+ const { nativeElement, componentInstance} = TestBed . createComponent ( Thing1 ) ;
2303+ expect ( nativeElement . textContent ) . toBe ( '' ) ; // change detection didn't run yet
2304+
2305+ componentInstance . state . set ( 2 ) ;
2306+ TestBed . tick ( ) ;
2307+ expect ( nativeElement . textContent ) . toBe ( '2' ) ;
2308+ } ) ;
2309+ } ) ;
2310+
2311+ describe ( 'with zoneless change detection' , ( ) => {
2312+ beforeEach ( ( ) => {
2313+ TestBed . configureTestingModule ( {
2314+ providers : [ provideZonelessChangeDetection ( ) ] ,
2315+ } ) ;
2316+ } ) ;
2317+
2318+ it ( 'should update fixtures with zoneless' , async ( ) => {
2319+ const fixture = TestBed . createComponent ( Thing1 ) ;
2320+ await fixture . whenStable ( ) ;
2321+
2322+ const { nativeElement, componentInstance} = fixture ;
2323+ expect ( nativeElement . textContent ) . toBe ( '1' ) ;
2324+
2325+ componentInstance . state . set ( 2 ) ;
2326+ TestBed . tick ( ) ;
2327+ expect ( nativeElement . textContent ) . toBe ( '2' ) ;
2328+ } ) ;
2329+ } ) ;
2330+ } ) ;
22762331} ) ;
22772332
22782333describe ( 'TestBed defer block behavior' , ( ) => {
0 commit comments