2017-04-28 11:34:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  testPackage  =  require ( '../../helpers/test-package' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  Dgeni  =  require ( 'dgeni' ) ;  
						 
					
						
							
								
									
										
										
										
											2017-04-27 14:04:51 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								const  plugin  =  require ( './autolink-headings' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								describe ( 'autolink-headings postprocessor' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  let  processor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  beforeEach ( ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 11:34:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    const  dgeni  =  new  Dgeni ( [ testPackage ( 'angular-base-package' ) ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  injector  =  dgeni . configureInjector ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    processor  =  injector . get ( 'postProcessHtml' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-27 14:04:51 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    processor . docTypes  =  [ 'a' ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    processor . plugins  =  [ plugin ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  it ( 'should add anchors to headings' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-15 03:01:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    const  originalContent  =  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h1 > Heading  1 < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h2 > Heading  with  < strong > bold < / s t r o n g > < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h3 > Heading  with  encoded  chars  & # x26 ; < / h 3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  processedContent  =  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-26 11:34:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      < h1  id = "heading-1" > Heading  1 < a  title = "Link to this heading"  class = "header-link"  aria - hidden = "true"  href = "#heading-1" > < i  class = "material-icons" > link < / i > < / a > < / h 1 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h2  id = "heading-with-bold" > Heading  with  < strong > bold < /strong><a title="Link to this heading" class="header-link" aria-hidden="true" href="#heading-with-bold"><i class="material-icons">link</i > < / a > < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h3  id = "heading-with-encoded-chars-" > Heading  with  encoded  chars  & # x26 ; < a  title = "Link to this heading"  class = "header-link"  aria - hidden = "true"  href = "#heading-with-encoded-chars-" > < i  class = "material-icons" > link < / i > < / a > < / h 3 > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-15 03:01:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  docs  =  [ { docType :  'a' ,  renderedContent :  originalContent } ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    processor . $process ( docs ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    expect ( docs [ 0 ] . renderedContent ) . toBe ( processedContent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  it ( 'should ignore headings with the `no-anchor` class' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  originalContent  =  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h1  class = "no-anchor" > Heading  1 < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h2  class = "no-anchor" > Heading  with  < strong > bold < / s t r o n g > < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h3  class = "no-anchor" > Heading  with  encoded  chars  & # x26 ; < / h 3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  processedContent  =  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h1  class = "no-anchor"  id = "heading-1" > Heading  1 < / h 1 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h2  class = "no-anchor"  id = "heading-with-bold" > Heading  with  < strong > bold < / s t r o n g > < / h 2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < h3  class = "no-anchor"  id = "heading-with-encoded-chars-" > Heading  with  encoded  chars  & # x26 ; < / h 3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  docs  =  [ { docType :  'a' ,  renderedContent :  originalContent } ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-27 14:04:51 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    processor . $process ( docs ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-15 03:01:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    expect ( docs [ 0 ] . renderedContent ) . toBe ( processedContent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-27 14:04:51 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;