diff --git a/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.spec.ts b/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.spec.ts index 59e3be62e3..d8534a7bfc 100644 --- a/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.spec.ts +++ b/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.spec.ts @@ -12,10 +12,30 @@ describe('MarkdownParserComponent', () => { fixture = TestBed.createComponent(MarkdownParserComponent) component = fixture.componentInstance - fixture.detectChanges() }) it('should create', () => { expect(component).toBeTruthy() }) + + it('should render markdown as HTML', () => { + component.textContent = '**bold markdown**' + fixture.detectChanges() + const markdown = fixture.nativeElement.innerHTML + expect(markdown).toContain('
bold markdown
') + }) + + it('should render HTML as HTML', () => { + component.textContent = 'simple html
' + fixture.detectChanges() + const html = fixture.nativeElement.innerHTML + expect(html).toContain('simple html
') + }) + + it('should render text as HTML', () => { + component.textContent = 'simple text' + fixture.detectChanges() + const text = fixture.nativeElement.innerHTML + expect(text).toContain('simple text
') + }) }) diff --git a/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts b/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts index a4fbf0c1a8..679462caf8 100644 --- a/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts +++ b/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts @@ -1,10 +1,11 @@ -import { Component, Input } from '@angular/core' +import { Component, Input, ChangeDetectionStrategy } from '@angular/core' import { marked } from 'marked' @Component({ selector: 'gn-ui-markdown-parser', templateUrl: './markdown-parser.component.html', styleUrls: ['./markdown-parser.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class MarkdownParserComponent { @Input() textContent: string