Skip to content

Commit

Permalink
[AAE-29971] added unit tests for projected content
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszhanaj committed Jan 10, 2025
1 parent 61d7c31 commit bb43776
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TaskScreenCloudComponent } from './screen-cloud.component';
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ScreenRenderingService } from '../../../services/public-api';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
import { ScreenRenderingService } from '../../../services/public-api';
import { TaskScreenCloudComponent } from './screen-cloud.component';

@Component({
selector: 'adf-cloud-test-component',
Expand All @@ -31,15 +30,27 @@ import { By } from '@angular/platform-browser';
})
class TestComponent {}

@Component({
selector: 'adf-cloud-test-actions-component',
template: `<adf-cloud-task-screen [taskId]="'1'" [appName]="'app-name-test'" [screenId]="'test'">
<div buttons class="adf-cloud-test-buttons">
<button>Test</button>
</div>
</adf-cloud-task-screen> `,
imports: [CommonModule, TaskScreenCloudComponent],
standalone: true
})
class TestWrapperComponent {}

describe('TaskScreenCloudComponent', () => {
let fixture: ComponentFixture<TaskScreenCloudComponent>;
let fixture: ComponentFixture<TestWrapperComponent>;
let screenRenderingService: ScreenRenderingService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [TaskScreenCloudComponent, TestComponent]
imports: [TaskScreenCloudComponent, TestComponent, TestWrapperComponent]
});
fixture = TestBed.createComponent(TaskScreenCloudComponent);
fixture = TestBed.createComponent(TestWrapperComponent);
screenRenderingService = TestBed.inject(ScreenRenderingService);
screenRenderingService.register({ ['test']: () => TestComponent });
fixture.componentRef.setInput('screenId', 'test');
Expand All @@ -50,4 +61,9 @@ describe('TaskScreenCloudComponent', () => {
const dynamicComponent = fixture.debugElement.query(By.css('.adf-cloud-test-container'));
expect(dynamicComponent).toBeTruthy();
});

it('should project content into component', async () => {
const projectedContent = fixture.debugElement.query(By.css('.adf-cloud-test-buttons'));
expect(projectedContent).toBeTruthy();
});
});

0 comments on commit bb43776

Please sign in to comment.