Skip to content

Commit 40fe4ea

Browse files
docs: use on in docs (#469)
Closes #468
1 parent 679c5f9 commit 40fe4ea

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

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

+57-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,62 @@ test('is possible to set input and listen for output', async () => {
77
const user = userEvent.setup();
88
const sendValue = jest.fn();
99

10+
await render(InputOutputComponent, {
11+
componentInputs: {
12+
value: 47,
13+
},
14+
on: {
15+
sendValue,
16+
},
17+
});
18+
19+
const incrementControl = screen.getByRole('button', { name: /increment/i });
20+
const sendControl = screen.getByRole('button', { name: /send/i });
21+
const valueControl = screen.getByTestId('value');
22+
23+
expect(valueControl).toHaveTextContent('47');
24+
25+
await user.click(incrementControl);
26+
await user.click(incrementControl);
27+
await user.click(incrementControl);
28+
expect(valueControl).toHaveTextContent('50');
29+
30+
await user.click(sendControl);
31+
expect(sendValue).toHaveBeenCalledTimes(1);
32+
expect(sendValue).toHaveBeenCalledWith(50);
33+
});
34+
35+
test.skip('is possible to set input and listen for output with the template syntax', async () => {
36+
const user = userEvent.setup();
37+
const sendSpy = jest.fn();
38+
39+
await render('<app-fixture [value]="47" (sendValue)="sendValue($event)" />', {
40+
imports: [InputOutputComponent],
41+
on: {
42+
sendValue: sendSpy,
43+
},
44+
});
45+
46+
const incrementControl = screen.getByRole('button', { name: /increment/i });
47+
const sendControl = screen.getByRole('button', { name: /send/i });
48+
const valueControl = screen.getByTestId('value');
49+
50+
expect(valueControl).toHaveTextContent('47');
51+
52+
await user.click(incrementControl);
53+
await user.click(incrementControl);
54+
await user.click(incrementControl);
55+
expect(valueControl).toHaveTextContent('50');
56+
57+
await user.click(sendControl);
58+
expect(sendSpy).toHaveBeenCalledTimes(1);
59+
expect(sendSpy).toHaveBeenCalledWith(50);
60+
});
61+
62+
test('is possible to set input and listen for output (deprecated)', async () => {
63+
const user = userEvent.setup();
64+
const sendValue = jest.fn();
65+
1066
await render(InputOutputComponent, {
1167
componentInputs: {
1268
value: 47,
@@ -34,7 +90,7 @@ test('is possible to set input and listen for output', async () => {
3490
expect(sendValue).toHaveBeenCalledWith(50);
3591
});
3692

37-
test('is possible to set input and listen for output with the template syntax', async () => {
93+
test('is possible to set input and listen for output with the template syntax (deprecated)', async () => {
3894
const user = userEvent.setup();
3995
const sendSpy = jest.fn();
4096

apps/example-app/src/app/examples/22-signal-inputs.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ test('output emits a value', async () => {
5555
greeting: 'Hello',
5656
name: 'world',
5757
},
58-
componentOutputs: {
59-
submit: { emit: submitFn } as any,
58+
on: {
59+
submit: submitFn,
6060
},
6161
});
6262

0 commit comments

Comments
 (0)