diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index 0e460b8..2d492d6 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -157,10 +157,7 @@ export async function render( } renderedPropKeys = Object.keys(newComponentProps); - if ( - properties?.detectChangesOnRender === true || - (properties?.detectChangesOnRender === undefined && detectChangesOnRender === true) - ) { + if (properties?.detectChangesOnRender !== false) { fixture.componentRef.injector.get(ChangeDetectorRef).detectChanges(); } }; diff --git a/projects/testing-library/tests/rerender.spec.ts b/projects/testing-library/tests/rerender.spec.ts index cde6c82..a06beaf 100644 --- a/projects/testing-library/tests/rerender.spec.ts +++ b/projects/testing-library/tests/rerender.spec.ts @@ -82,39 +82,13 @@ test('rerenders the component with updated props and resets other props', async }); }); -describe('detectChangesOnRender', () => { - test('change detection gets not called if disabled within render', async () => { - const { rerender, detectChanges } = await render(FixtureComponent, { detectChangesOnRender: false }); - detectChanges(); - expect(screen.getByText('Sarah')).toBeInTheDocument(); - - const firstName = 'Mark'; - await rerender({ componentInputs: { firstName } }); - - expect(screen.getByText('Sarah')).toBeInTheDocument(); - expect(screen.queryByText(firstName)).not.toBeInTheDocument(); - }); - - test('change detection gets called if disabled within render but enabled within rerender', async () => { - const { rerender, detectChanges } = await render(FixtureComponent, { detectChangesOnRender: false }); - detectChanges(); - expect(screen.getByText('Sarah')).toBeInTheDocument(); - - const firstName = 'Mark'; - await rerender({ componentInputs: { firstName }, detectChangesOnRender: true }); - - expect(screen.getByText(firstName)).toBeInTheDocument(); - expect(screen.queryByText('Sarah')).not.toBeInTheDocument(); - }); - - test('change detection gets not called if disabled within rerender', async () => { - const { rerender } = await render(FixtureComponent); - expect(screen.getByText('Sarah')).toBeInTheDocument(); +test('change detection gets not called if `detectChangesOnRender` is set to false', async () => { + const { rerender } = await render(FixtureComponent); + expect(screen.getByText('Sarah')).toBeInTheDocument(); - const firstName = 'Mark'; - await rerender({ componentInputs: { firstName }, detectChangesOnRender: false }); + const firstName = 'Mark'; + await rerender({ componentInputs: { firstName }, detectChangesOnRender: false }); - expect(screen.getByText('Sarah')).toBeInTheDocument(); - expect(screen.queryByText(firstName)).not.toBeInTheDocument(); - }); + expect(screen.getByText('Sarah')).toBeInTheDocument(); + expect(screen.queryByText(firstName)).not.toBeInTheDocument(); });