Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b1ac6b8

Browse files
committedFeb 26, 2024
docs: add signal input component test
1 parent a709ae5 commit b1ac6b8

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed
 
Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
import { render, screen } from '@testing-library/angular';
22
import { SignalInputComponent } from './22-signal-inputs.component';
3-
import { Component } from '@angular/core';
43

5-
test('works with signal inputs using a wrapper component', async () => {
6-
@Component({
7-
template: `
8-
<app-signal-input [greeting]="greeting" [name]="name"/>
9-
`,
10-
standalone: true,
11-
imports: [SignalInputComponent],
12-
})
13-
class WrapperComponent {
14-
greeting = 'Hello';
15-
name = 'world';
16-
}
4+
test('works with signal inputs', async () => {
5+
await render(SignalInputComponent, {
6+
componentInputs: {
7+
name: 'world',
8+
greeting: 'Hello',
9+
},
10+
});
1711

18-
await render(WrapperComponent);
12+
expect(screen.getByText(/hello world/i)).toBeInTheDocument();
13+
});
14+
15+
test('works with signal inputs and rerenders', async () => {
16+
const view = await render(SignalInputComponent, {
17+
componentInputs: {
18+
greeting: 'Hello',
19+
name: 'world',
20+
},
21+
});
1922

2023
expect(screen.getByText(/hello world/i)).toBeInTheDocument();
24+
25+
await view.rerender({
26+
componentInputs: {
27+
greeting: 'bye',
28+
name: 'test',
29+
},
30+
});
31+
32+
expect(screen.getByText(/bye test/i)).toBeInTheDocument();
2133
});

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"eslint-plugin-testing-library": "~5.0.1",
8484
"jasmine-core": "4.2.0",
8585
"jasmine-spec-reporter": "7.0.0",
86-
"jest": "29.5.0",
86+
"jest": "29.7.0",
8787
"jest-environment-jsdom": "29.5.0",
8888
"jest-preset-angular": "14.0.3",
8989
"karma": "6.4.0",

0 commit comments

Comments
 (0)
Please sign in to comment.