[AAE-17551] added backgroundImage property for header (#9058)

* [AAE-17551] added backgroundImage property for header

* [AAE-17551] added test for background image

* [AAE-17551] removed some material selectors

* [AAE-17551] rebasing

* [AAE-17551] fixed unit test
This commit is contained in:
Wojciech Duda 2023-11-04 15:06:11 +01:00 committed by GitHub
parent 94fb61541c
commit a29f63cd9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 8 deletions

View File

@ -1,6 +1,6 @@
<mat-toolbar
[color]="color"
[style.background-color]="color">
[style.background-image]="'url(' + backgroundImage + ')'">
<button
*ngIf="showSidenavToggle && position === 'start'"
id="adf-sidebar-toggle-start"

View File

@ -35,11 +35,14 @@ describe('HeaderLayoutComponent', () => {
describe('Input parameters', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), CoreTestingModule]
imports: [
TranslateModule.forRoot(),
CoreTestingModule
]
});
fixture = TestBed.createComponent(HeaderLayoutComponent);
component = fixture.componentInstance;
loader = TestbedHarnessEnvironment.loader(fixture);
component = fixture.componentInstance;
});
afterEach(() => {
@ -69,6 +72,15 @@ describe('HeaderLayoutComponent', () => {
expect(await host.getAttribute('ng-reflect-color')).toBe('primary');
});
it('should change background image when provided', async () => {
component.backgroundImage = '/assets/someImage.png';
fixture.detectChanges();
const toolbarHarness = await loader.getHarness(MatToolbarHarness);
const toolbar = await toolbarHarness.host();
expect(await toolbar.getCssValue('background-image')).toContain('/assets/someImage.png');
});
it('should display the img element with the expected src if a logo path is set', () => {
component.logo = 'logo.png';
fixture.detectChanges();
@ -78,7 +90,7 @@ describe('HeaderLayoutComponent', () => {
expect(src).toEqual('logo.png');
});
it('should have custom url link set on logo when the redirectUrl is set', () => {
it('should have custom url link set on logo when the redirectUrl is set', async () => {
component.redirectUrl = '/customHomePage';
fixture.detectChanges();
@ -218,10 +230,11 @@ describe('HeaderLayoutComponent', () => {
describe('Template transclusion', () => {
@Component({
selector: 'adf-test-layout-header',
template: `<adf-layout-header title="test" color="primary"
><p>Test text</p>
<p></p
></adf-layout-header>`
template: `
<adf-layout-header title="test" color="primary">
<p>Test text</p>
<p></p>
</adf-layout-header>`
})
class HeaderLayoutTesterComponent {}

View File

@ -48,6 +48,9 @@ export class HeaderLayoutComponent implements OnInit {
*/
@Input() color: ThemePalette;
/** Path to a background image for the header. */
@Input() backgroundImage: string;
/**
* Toggles whether the sidenav button will be displayed in the header
* or not.