diff --git a/projects/testing-library/src/lib/models.ts b/projects/testing-library/src/lib/models.ts index 0a9b78a..c1c68c2 100644 --- a/projects/testing-library/src/lib/models.ts +++ b/projects/testing-library/src/lib/models.ts @@ -196,7 +196,7 @@ export interface RenderComponentOptions; + componentInputs?: Partial | { [alias: string]: unknown }; /** * @description * An object to set `@Output` properties of the component diff --git a/projects/testing-library/tests/issues/issue-386.spec.ts b/projects/testing-library/tests/issues/issue-386.spec.ts new file mode 100644 index 0000000..a2a4786 --- /dev/null +++ b/projects/testing-library/tests/issues/issue-386.spec.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { throwError } from 'rxjs'; +import userEvent from '@testing-library/user-event'; +import { render, screen } from '../../src/public_api'; + +@Component({ + selector: 'atl-fixture', + template: ``, + styles: [], +}) +class TestComponent { + onTest() { + throwError(() => new Error('myerror')).subscribe(); + } +} + +describe('TestComponent', () => { + beforeEach(() => { + jest.useFakeTimers(); + }); + + afterEach(() => { + jest.runAllTicks(); + jest.useRealTimers(); + }); + + it('does not fail', async () => { + await render(TestComponent); + await userEvent.click(screen.getByText('Test')); + }); + + it('fails because of the previous one', async () => { + await render(TestComponent); + await userEvent.click(screen.getByText('Test')); + }); +}); diff --git a/projects/testing-library/tests/issues/issue-389.spec.ts b/projects/testing-library/tests/issues/issue-389.spec.ts new file mode 100644 index 0000000..03f25f7 --- /dev/null +++ b/projects/testing-library/tests/issues/issue-389.spec.ts @@ -0,0 +1,16 @@ +import { Component, Input } from '@angular/core'; +import { render, screen } from '../../src/public_api'; + +@Component({ + selector: 'atl-fixture', + template: `Hello {{ name }}`, +}) +class TestComponent { + // eslint-disable-next-line @angular-eslint/no-input-rename + @Input('aliasName') name = ''; +} + +test('allows you to set componentInputs using the name alias', async () => { + await render(TestComponent, { componentInputs: { aliasName: 'test' } }); + expect(screen.getByText('Hello test')).toBeInTheDocument(); +});