-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { Component, Inject, Injectable } from '@angular/core'; | ||
import { screen, render } from '../../src/public_api'; | ||
|
||
// Service | ||
@Injectable() | ||
class DemoService { | ||
buttonTitle = new BehaviorSubject<string>('Click me'); | ||
} | ||
|
||
// Component | ||
@Component({ | ||
selector: 'atl-issue-435', | ||
standalone: true, | ||
imports: [CommonModule], | ||
providers: [DemoService], | ||
template: ` | ||
<button> | ||
<!-- 👇 I only get the Inject error when I use the async pipe here --> | ||
{{ demoService.buttonTitle | async }} | ||
</button> | ||
`, | ||
}) | ||
class DemoComponent { | ||
constructor(@Inject(DemoService) public demoService: DemoService) {} | ||
} | ||
|
||
// Test | ||
describe('DemoComponent', () => { | ||
it('should render button', async () => { | ||
await render(DemoComponent); | ||
|
||
const button = screen.getByRole('button', { | ||
name: /Click me/, | ||
}); | ||
|
||
expect(button).toBeVisible(); | ||
}); | ||
}); |