diff --git a/projects/core/components/link/test/link.directive.spec.ts b/projects/core/components/link/test/link.directive.spec.ts new file mode 100644 index 000000000000..8a2052ad3ac4 --- /dev/null +++ b/projects/core/components/link/test/link.directive.spec.ts @@ -0,0 +1,65 @@ +import type {HarnessLoader} from '@angular/cdk/testing'; +import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; +import {Component} from '@angular/core'; +import {type ComponentFixture, TestBed} from '@angular/core/testing'; +import {TuiLinkHarness} from '@taiga-ui/testing'; + +import {TuiLink} from '../link.directive'; + +describe('LinkDirective', () => { + @Component({ + standalone: true, + imports: [TuiLink], + template: ` + + No Pseudo + + + + Pseudo Link + + `, + }) + class Test {} + + let fixture: ComponentFixture; + let loader: HarnessLoader; + + beforeEach(async () => { + TestBed.configureTestingModule({ + imports: [Test], + }); + await TestBed.compileComponents(); + fixture = TestBed.createComponent(Test); + loader = TestbedHarnessEnvironment.loader(fixture); + + fixture.detectChanges(); + }); + + describe('pseudo:', () => { + it('should not have underline when pseudo is false', async () => { + const link = await loader.getHarness( + TuiLinkHarness.with({selector: '#link-no-pseudo'}), + ); + + expect(await link.isPseudo()).toBeFalsy(); + }); + + it('should have underline when pseudo is true', async () => { + const link = await loader.getHarness( + TuiLinkHarness.with({selector: '#pseudo-link'}), + ); + + expect(await link.isPseudo()).toBeTruthy(); + }); + }); +}); diff --git a/projects/testing/core/index.ts b/projects/testing/core/index.ts index 6d97651785bf..ca08bbfa6a46 100644 --- a/projects/testing/core/index.ts +++ b/projects/testing/core/index.ts @@ -11,6 +11,7 @@ export * from './card.harness'; export * from './dialog.harness'; export * from './dropdown-open.harness'; export * from './island.harness'; +export * from './link.harness'; export * from './loader.harness'; export * from './primitive-textfield.harness'; export * from './select.harness'; diff --git a/projects/testing/core/link.harness.ts b/projects/testing/core/link.harness.ts new file mode 100644 index 000000000000..02f6f32c02c2 --- /dev/null +++ b/projects/testing/core/link.harness.ts @@ -0,0 +1,13 @@ +import {TuiComponentHarness} from '@taiga-ui/testing/utils'; + +export class TuiLinkHarness extends TuiComponentHarness { + public static hostSelector = 'a[tuiLink], button[tuiLink]'; + + public async isPseudo(): Promise { + return ( + (await (await this.host()).getAttribute('style'))?.includes( + 'text-decoration-line: underline', + ) ?? false + ); + } +}