From 8879f69c2d017c262d7175937d1cf2b6ad08581f Mon Sep 17 00:00:00 2001 From: Angelika Kinas Date: Thu, 21 Dec 2023 17:24:37 +0100 Subject: [PATCH] WIP: Add test for html input --- .../metadata-info/linkify.directive.spec.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libs/ui/elements/src/lib/metadata-info/linkify.directive.spec.ts b/libs/ui/elements/src/lib/metadata-info/linkify.directive.spec.ts index 1b0c8c7471..9877db18ee 100644 --- a/libs/ui/elements/src/lib/metadata-info/linkify.directive.spec.ts +++ b/libs/ui/elements/src/lib/metadata-info/linkify.directive.spec.ts @@ -62,11 +62,20 @@ const testWithMultipleUrls = { ], } +const testWithHTML = { + input: + '

Fourteenth link with html input This is the display text query params

', + output: 'http://foo.com/(something)?after=before', +} + @Component({ - template: `
{{ text }}
`, + template: `
+ {{ text }} +
`, }) class TestComponent { text = '' + customInnerHTML = null } describe('GnUiLinkifyDirective', () => { @@ -123,4 +132,16 @@ describe('GnUiLinkifyDirective', () => { ) return debugElement.queryAll(By.css('a')) } + + describe('HTML input', () => { + it('should create an anchor element with the correct href', async () => { + component.customInnerHTML = testWithHTML.input + fixture.detectChanges() + await fixture.whenStable() + const href = getAnchorElement()[0].nativeElement.getAttribute('href') + const matIcon = getAnchorElement()[0].nativeElement.childNodes[1] + expect(href).toBe(testWithHTML.output) + expect(matIcon.nodeName).toContain('MAT-ICON') + }) + }) })