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