Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/example-app/src/app/examples/02-input-output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ test('is possible to set input and listen for output', async () => {
test('is possible to set input and listen for output with the template syntax', async () => {
const sendSpy = jest.fn();

await render(InputOutputComponent, {
template: '<app-fixture [value]="47" (sendValue)="sendValue($event)" (clicked)="clicked()"></app-fixture>',
await render('<app-fixture [value]="47" (sendValue)="sendValue($event)" (clicked)="clicked()"></app-fixture>', {
declarations: [InputOutputComponent],
componentProperties: {
sendValue: sendSpy,
},
Expand Down
6 changes: 2 additions & 4 deletions apps/example-app/src/app/examples/11-ng-content.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { render, screen } from '@testing-library/angular';

import { CellComponent } from './11-ng-content';

test('it is possible 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: `<cell data-testid="one-cell-with-ng-content">${projection}</cell>`,
await render(`<app-fixture data-testid="one-cell-with-ng-content">${projection}</app-fixture>`, {
declarations: [CellComponent]
});

expect(screen.getByText(projection)).toBeInTheDocument();
Expand Down
1 change: 1 addition & 0 deletions apps/example-app/src/app/examples/11-ng-content.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';

@Component({
selector: 'app-fixture',
template: `
<p>
<ng-content></ng-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render, screen } from '@testing-library/angular';
import {ComponentWithAttributeSelectorComponent} from './17-component-with-attribute-selector';

// Note: At this stage it is not possible to use the render(ComponentWithAttributeSelectorComponent, {...}) syntax
// for components with attribute selectors!
test('is possible to set input of component with attribute selector through template', async () => {
await render(`<app-fixture-component-with-attribute-selector [value]="42"></app-fixture-component-with-attribute-selector>`, {
declarations: [ComponentWithAttributeSelectorComponent]
});

const valueControl = screen.getByTestId('value');

expect(valueControl).toHaveTextContent('42');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component, Input } from '@angular/core';

@Component({
selector: 'app-fixture-component-with-attribute-selector[value]',
template: `
<span data-testid="value">{{ value }}</span>
`,
})
export class ComponentWithAttributeSelectorComponent {
@Input() value!: number;
}