Skip to content

Commit 20a7e6a

Browse files
test: add test case for #386 (#387)
1 parent a3dfe42 commit 20a7e6a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {Component} from '@angular/core';
2+
import {throwError} from 'rxjs';
3+
import {render, screen} from '@testing-library/angular';
4+
import userEvent from '@testing-library/user-event';
5+
6+
@Component({
7+
selector: 'app-test',
8+
template: `<button (click)="onTest()">Test</button>`,
9+
styles: [],
10+
})
11+
export class TestComponent {
12+
onTest() {
13+
throwError(() => new Error('myerror')).subscribe();
14+
}
15+
}
16+
17+
18+
describe('TestComponent', () => {
19+
beforeEach(() => {
20+
jest.useFakeTimers();
21+
});
22+
23+
afterEach(() => {
24+
jest.runAllTicks();
25+
jest.useRealTimers();
26+
})
27+
28+
it('does not fail', async () => {
29+
await render(TestComponent);
30+
await userEvent.click(screen.getByText('Test'));
31+
});
32+
33+
it('fails because of the previous one', async () => {
34+
await render(TestComponent);
35+
await userEvent.click(screen.getByText('Test'));
36+
});
37+
});

0 commit comments

Comments
 (0)