Skip to content

Commit 4fe225c

Browse files
committed
docs: add template syntax example for component properties
1 parent 1672764 commit 4fe225c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

apps/example-app/app/examples/02-input-output.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,29 @@ test('is possible to set input and listen for output', async () => {
2929
expect(sendValue).toHaveBeenCalledTimes(1);
3030
expect(sendValue).toHaveBeenCalledWith(50);
3131
});
32+
33+
test('is possible to set input and listen for output with the template syntax', async () => {
34+
const sendSpy = jest.fn();
35+
36+
await render(InputOutputComponent, {
37+
template: `<app-fixture [value]="47" (sendValue)="sendValue($event)" (clicked)="clicked()"></app-fixture>`,
38+
componentProperties: {
39+
sendValue: sendSpy,
40+
},
41+
});
42+
43+
const incrementControl = screen.getByRole('button', { name: /increment/i });
44+
const sendControl = screen.getByRole('button', { name: /send/i });
45+
const valueControl = screen.getByTestId('value');
46+
47+
expect(valueControl.textContent).toBe('47');
48+
49+
fireEvent.click(incrementControl);
50+
fireEvent.click(incrementControl);
51+
fireEvent.click(incrementControl);
52+
expect(valueControl.textContent).toBe('50');
53+
54+
fireEvent.click(sendControl);
55+
expect(sendSpy).toHaveBeenCalledTimes(1);
56+
expect(sendSpy).toHaveBeenCalledWith(50);
57+
});

0 commit comments

Comments
 (0)