File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change
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 { }
You can’t perform that action at this time.
0 commit comments