Skip to content

Commit fd720f9

Browse files
test: add ng-content example
Closes #78
2 parents a67955e + 793c9e2 commit fd720f9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { render, screen } from '@testing-library/angular';
3+
4+
import { CellComponent } from './11-ng-content';
5+
6+
test('it is posible to test ng-content without selector', async () => {
7+
const projection = 'it should be showed into a p element!';
8+
9+
TestBed.overrideComponent(CellComponent, { set: { selector: 'cell' } });
10+
await render(CellComponent, {
11+
template: `<cell data-testid="one-cell-with-ng-content">${projection}</cell>`,
12+
});
13+
14+
expect(screen.getByText(projection)).toBeInTheDocument();
15+
expect(screen.getByTestId('one-cell-with-ng-content')).toContainHTML(`<p>${projection}</p>`);
16+
});

src/app/examples/11-ng-content.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component, ChangeDetectionStrategy } from '@angular/core';
2+
3+
@Component({
4+
template: `
5+
<p>
6+
<ng-content></ng-content>
7+
</p>
8+
`,
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
})
11+
export class CellComponent {}

0 commit comments

Comments
 (0)