Skip to content

Commit

Permalink
docs: add signal input test
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Feb 26, 2024
1 parent b01a933 commit f78be95
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render, screen } from '@testing-library/angular';
import { SignalInputComponent } from './22-signal-inputs.component';
import { Component } from '@angular/core';

test('works with signal inputs using a wrapper component', async () => {
@Component({
template: `
<app-signal-input [greeting]="greeting" [name]="name"/>
`,
standalone: true,
imports: [SignalInputComponent],
})
class WrapperComponent {
greeting = 'Hello';
name = 'world';
}

await render(WrapperComponent);

expect(screen.getByText(/hello world/i)).toBeInTheDocument();
});
13 changes: 13 additions & 0 deletions apps/example-app/src/app/examples/22-signal-inputs.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component, input } from '@angular/core';

@Component({
selector: 'app-signal-input',
template: ` {{ greetings() }} {{ name() }} `,
standalone: true,
})
export class SignalInputComponent {
greetings = input<string>('', {
alias: 'greeting',
});
name = input.required<string>();
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"jasmine-spec-reporter": "7.0.0",
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"jest-preset-angular": "13.1.6",
"jest-preset-angular": "14.0.3",
"karma": "6.4.0",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.2.1",
Expand Down

0 comments on commit f78be95

Please sign in to comment.