Skip to content

Commit b263c00

Browse files
pkozlowski-opensourcedevversion
authored andcommitted
test: add basic test for event listeners
Adding a passing test for a listener invocation that changes signal value.
1 parent 3bd2fcd commit b263c00

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

packages/core/test/acceptance/signal-components/listeners.spec.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,29 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {Component, signal} from '@angular/core';
10+
import {TestBed} from '@angular/core/testing';
11+
912
describe('listeners', () => {
10-
it('should be able to invoke a listener',
11-
() => {
12-
// todo: listener restore view was missing.
13-
// in template pipeline
14-
});
13+
it('should invoke listeners that modify context data', () => {
14+
@Component({
15+
signals: true,
16+
standalone: true,
17+
template: `<button (click)="counter.set(1)">{{counter()}}</button>`,
18+
})
19+
class App {
20+
counter = signal(0);
21+
}
22+
23+
const fixture = TestBed.createComponent(App);
24+
25+
fixture.detectChanges();
26+
expect(fixture.nativeElement.textContent).toBe('0');
27+
28+
fixture.nativeElement.firstChild.click();
29+
fixture.detectChanges();
30+
expect(fixture.nativeElement.textContent).toBe('1');
31+
});
1532
});
33+
34+
// todo: listener restore view was missing in template pipeline

0 commit comments

Comments
 (0)