1+ /* eslint-disable max-classes-per-file */
12import {
23 Component ,
34 DebugElement ,
@@ -21,6 +22,14 @@ import { MarkdownDirective } from './markdown.directive';
2122} )
2223class TestComponent { }
2324
25+ @Component ( {
26+ template : `<div [dsMarkdown]="'Les informations demandés.es ne sont pas disponibles.'"></div>` ,
27+ imports : [
28+ MarkdownDirective ,
29+ ] ,
30+ } )
31+ class LinkifyTestComponent { }
32+
2433describe ( 'MarkdownDirective' , ( ) => {
2534 let fixture : ComponentFixture < TestComponent > ;
2635
@@ -55,10 +64,9 @@ describe('MarkdownDirective sanitization with markdown disabled', () => {
5564 } ) . compileComponents ( ) ;
5665 fixture = TestBed . createComponent ( TestComponent ) ;
5766 divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
58-
5967 } ) ;
6068
61- it ( 'should sanitize the script element out of innerHTML (markdown disabled)' , ( ) => {
69+ it ( 'should sanitize the script element out of innerHTML (markdown disabled)' , ( ) => {
6270 fixture . detectChanges ( ) ;
6371 divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
6472 expect ( divEl . nativeElement . innerHTML ) . toEqual ( 'test' ) ;
@@ -80,13 +88,37 @@ describe('MarkdownDirective sanitization with markdown enabled', () => {
8088 } ) . compileComponents ( ) ;
8189 fixture = TestBed . createComponent ( TestComponent ) ;
8290 divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
83-
8491 } ) ;
8592
86- it ( 'should sanitize the script element out of innerHTML (markdown enabled)' , ( ) => {
93+ it ( 'should sanitize the script element out of innerHTML (markdown enabled)' , ( ) => {
8794 fixture . detectChanges ( ) ;
8895 divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
8996 expect ( divEl . nativeElement . innerHTML ) . toEqual ( 'test' ) ;
9097 } ) ;
9198
9299} ) ;
100+
101+ describe ( 'MarkdownDirective linkify with markdown enabled' , ( ) => {
102+ let fixture : ComponentFixture < LinkifyTestComponent > ;
103+ let divEl : DebugElement ;
104+ // Enable markdown
105+ environment . markdown . enabled = true ;
106+
107+ beforeEach ( async ( ) => {
108+ await TestBed . configureTestingModule ( {
109+ providers : [
110+ { provide : MathService , useClass : MockMathService } ,
111+ ] ,
112+ } ) . compileComponents ( ) ;
113+ fixture = TestBed . createComponent ( LinkifyTestComponent ) ;
114+ divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
115+ } ) ;
116+
117+ it ( 'should not convert words with dots (e.g. demandés.es) to links (#2789)' , async ( ) => {
118+ fixture . detectChanges ( ) ;
119+ await fixture . whenStable ( ) ;
120+ divEl = fixture . debugElement . query ( By . css ( 'div' ) ) ;
121+ expect ( divEl . nativeElement . innerHTML ) . not . toContain ( '<a href' ) ;
122+ } ) ;
123+
124+ } ) ;
0 commit comments