Skip to content

Commit

Permalink
test(core): ExpressionChanged... error does not happen with signals (a…
Browse files Browse the repository at this point in the history
…ngular#54206)

This test ensures that the `ExpressionChanged...` error does not happen
when signals are updated in a view that is attached to `ApplicationRef`
but was already checked. This was fixed in 432afd1
which actually consequently fixes it for regular `markForCheck` as well.

PR Close angular#54206
  • Loading branch information
atscott authored and thePunderWoman committed Feb 2, 2024
1 parent fc5fe3e commit 74aa8a3
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ describe('CheckAlways components', () => {
incrementAfterCheckedUntil = Number.MAX_SAFE_INTEGER;
expect(() => fixture.detectChanges()).toThrowError(/Infinite/);
});

it('refreshes all views attached to ApplicationRef until no longer dirty', () => {
const val = signal(0);
@Component({
template: '{{val()}}',
standalone: true,
})
class App {
val = val;
ngOnInit() {
this.val.update(v => v+1);
}
}
const fixture = TestBed.createComponent(App);
const fixture2 = TestBed.createComponent(App);
const appRef = TestBed.inject(ApplicationRef);
appRef.attachView(fixture.componentRef.hostView);
appRef.attachView(fixture2.componentRef.hostView);

appRef.tick();
expect(fixture.nativeElement.innerText).toEqual('2');
expect(fixture2.nativeElement.innerText).toEqual('2');
});
});


Expand Down

0 comments on commit 74aa8a3

Please # to comment.