Skip to content
Snippets Groups Projects
Commit 16ba4a56 authored by Alexander Reifschneider's avatar Alexander Reifschneider
Browse files

OZG-7707 show sr label with if

parent b599d385
No related branches found
No related tags found
1 merge request!114OZG-7707 angular svg icon
...@@ -21,16 +21,20 @@ ...@@ -21,16 +21,20 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils';
import { provideHttpClient } from '@angular/common/http'; import { provideHttpClient } from '@angular/common/http';
import { provideZoneChangeDetection } from '@angular/core'; import { provideZoneChangeDetection } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideAngularSvgIcon } from 'angular-svg-icon'; import { provideAngularSvgIcon } from 'angular-svg-icon';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { IconComponent } from './icon.component'; import { IconComponent } from './icon.component';
describe('IconComponent', () => { describe('IconComponent', () => {
let component: IconComponent; let component: IconComponent;
let fixture: ComponentFixture<IconComponent>; let fixture: ComponentFixture<IconComponent>;
const labelSelector: string = getDataTestIdOf('sr-label');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [IconComponent], imports: [IconComponent],
...@@ -45,4 +49,24 @@ describe('IconComponent', () => { ...@@ -45,4 +49,24 @@ describe('IconComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('component', () => {
describe('label', () => {
it('should show', () => {
component.label = 'test';
fixture.detectChanges();
existsAsHtmlElement(fixture, labelSelector);
});
it('should hide', () => {
component.label = '';
fixture.detectChanges();
notExistsAsHtmlElement(fixture, labelSelector);
});
});
});
}); });
...@@ -60,7 +60,9 @@ type IconVariants = VariantProps<typeof iconVariants>; ...@@ -60,7 +60,9 @@ type IconVariants = VariantProps<typeof iconVariants>;
[svgClass]="twMerge(iconVariants({ size, fill }), class)" [svgClass]="twMerge(iconVariants({ size, fill }), class)"
aria-hidden="true" aria-hidden="true"
/> />
<span class="sr-only empty:hidden">{{ label }}</span>`, @if (label) {
<span class="sr-only" data-test-id="sr-label">{{ label }}</span>
}`,
styles: [':host {@apply block size-fit}'], styles: [':host {@apply block size-fit}'],
}) })
export class IconComponent { export class IconComponent {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment