diff --git a/src/app/examples/11-ng-content.spec.ts b/src/app/examples/11-ng-content.spec.ts new file mode 100644 index 00000000..85f2a49f --- /dev/null +++ b/src/app/examples/11-ng-content.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; +import { render, screen } from '@testing-library/angular'; + +import { CellComponent } from './11-ng-content'; + +test('it is posible to test ng-content without selector', async () => { + const projection = 'it should be showed into a p element!'; + + TestBed.overrideComponent(CellComponent, { set: { selector: 'cell' } }); + await render(CellComponent, { + template: `${projection}`, + }); + + expect(screen.getByText(projection)).toBeInTheDocument(); + expect(screen.getByTestId('one-cell-with-ng-content')).toContainHTML(`

${projection}

`); +}); diff --git a/src/app/examples/11-ng-content.ts b/src/app/examples/11-ng-content.ts new file mode 100644 index 00000000..302563f1 --- /dev/null +++ b/src/app/examples/11-ng-content.ts @@ -0,0 +1,11 @@ +import { Component, ChangeDetectionStrategy } from '@angular/core'; + +@Component({ + template: ` +

+ +

+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class CellComponent {}