| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  | import { expect } from 'chai'; | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | import { fuzzyTest, hasInlineText, kernelText, normalizeLines, tokenize } from './utils'; | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe(' 工具函数', () => { | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   it('把“1. ”列表处理成空行分隔的格式,以便处理', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  |     const lines = normalizeLines(`1. abc
 | 
					
						
							|  |  |  | 11. def | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`1. abc
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | 11. def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   it('把“- ”列表处理成空行分隔的格式,以便处理', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  |     const lines = normalizeLines(`- abc
 | 
					
						
							|  |  |  | - def | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`- abc
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | - def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('把“* ”列表处理成空行分隔的格式,以便处理', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  |     const lines = normalizeLines(`* abc
 | 
					
						
							|  |  |  | * def | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`* abc
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | * def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('把“# ”标题处理成空行分隔的格式,以便处理', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`\n# abc
 | 
					
						
							|  |  |  | def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`# abc
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:08:10 +08:00
										 |  |  |   it('拆解单行的成对 tag', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <div class="abc">DEF</div> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:08:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <div class="abc">DEF</div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:08:10 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-06 17:18:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   it('拆解单行的自封闭 tag', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <hr/> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:18:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <hr/> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:18:33 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   it('拆解单行的 h\\d 标签', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <h3 id="abc">line</h3> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:08:44 +08:00
										 |  |  |     <h3 id="abc">line</h3> | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 14:19:47 +08:00
										 |  |  |   it('把多行 hn 处理成单行', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  |     const lines = normalizeLines(`
 | 
					
						
							| 
									
										
										
										
											2018-03-07 14:19:47 +08:00
										 |  |  |     <h3 id="nav"> | 
					
						
							|  |  |  |       abc | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  |     </h3> | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`<h3 id="nav">abc</h3>`); | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   it('拆解单行的 th 标签', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <th>line</th> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <th> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |         line | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     </th> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('拆解单行注释', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <!-- no --> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <!-- no --> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  |   it('拆解多行注释', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <!-- no
 | 
					
						
							|  |  |  |     abc --> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <!-- no
 | 
					
						
							|  |  |  |     abc --> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 12:26:05 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:29:06 +08:00
										 |  |  |   it('拆解单行br', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <br class="clear"> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:29:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <br class="clear"> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:29:06 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |   it('拆解 code-example', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | abc | 
					
						
							|  |  |  | <code-example | 
					
						
							|  |  |  | language="sh" class="code-shell"> | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  | ng generate directive highlight | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | </code-example> | 
					
						
							|  |  |  | def | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`abc
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | <code-example | 
					
						
							|  |  |  | language="sh" class="code-shell"> | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  | ng generate directive highlight | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | </code-example> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def`);
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('不拆解引用的 code-example', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  | abc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | > <code-example > abc </code-example> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`abc
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | > <code-example > abc </code-example> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |   it('为单行的 li 和 ul 前后添加空行', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     <li> | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  |     </li> | 
					
						
							|  |  |  |     c | 
					
						
							|  |  |  |     <ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </ul> | 
					
						
							|  |  |  |     `);
 | 
					
						
							|  |  |  |     expect(normalizeLines(lines)).eql(`a
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <li> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     </li> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     c | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </ul>`);
 | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   it('拆解 @a 标记', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     {@a test} | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     {@a test} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('拆解多行代码', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     a | 
					
						
							|  |  |  |     \`\`\`
 | 
					
						
							|  |  |  |       var a = 1 | 
					
						
							|  |  |  |     \`\`\`
 | 
					
						
							|  |  |  |     b | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     \`\`\`
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       var a = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     \`\`\`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |   it('把多行的 p 元素合并成单行', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 08:42:26 +08:00
										 |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |     <p> | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |         a | 
					
						
							| 
									
										
										
										
											2018-03-07 08:42:26 +08:00
										 |  |  |     </p> | 
					
						
							|  |  |  |     <p> | 
					
						
							|  |  |  |     一 | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eq(`<p>a</p>
 | 
					
						
							| 
									
										
										
										
											2018-03-07 08:42:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     <p>一</p>`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 11:31:12 +08:00
										 |  |  |   it('不要拆解 header', function () { | 
					
						
							|  |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |   <header>Angular forms don't require a style library</header> | 
					
						
							|  |  |  | `);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eq(`<header>Angular forms don't require a style library</header>`); | 
					
						
							| 
									
										
										
										
											2018-03-24 11:31:12 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:21:16 +08:00
										 |  |  |   it('拆解独行的 th/td', function () { | 
					
						
							|  |  |  |     expect(normalizeLines(`
 | 
					
						
							|  |  |  |   <td> | 
					
						
							|  |  |  |     abc | 
					
						
							|  |  |  |   </td> | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | `)).eql(`<td> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:21:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     abc | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |   </td>`);
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('拆解 pre', function () { | 
					
						
							|  |  |  |     expect(normalizeLines(`
 | 
					
						
							|  |  |  |     ABC | 
					
						
							|  |  |  |     <pre>def</pre> | 
					
						
							|  |  |  |     ghi | 
					
						
							|  |  |  | `)).eql(`ABC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <pre>def</pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ghi`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:33:42 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-07 12:45:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   it('拆解任意位置的 <tr>', function () { | 
					
						
							|  |  |  |     expect(normalizeLines(`
 | 
					
						
							|  |  |  |   <tr><td>abc</td></tr> | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | `)).eql(`<tr> | 
					
						
							| 
									
										
										
										
											2018-03-07 12:45:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 13:09:36 +08:00
										 |  |  |       <td> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           abc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       </td> | 
					
						
							| 
									
										
										
										
											2018-03-07 12:45:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |   </tr>`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 12:45:12 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-07 09:33:42 +08:00
										 |  |  |   it('拆解独行的 li', function () { | 
					
						
							|  |  |  |     expect(normalizeLines(`
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | <ul> | 
					
						
							|  |  |  | <li><a href="#">a</a></li> | 
					
						
							|  |  |  | <li><a href="#">b</a></li> | 
					
						
							|  |  |  | <li><a href="#">c</a></li> | 
					
						
							|  |  |  | </ul> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | `)).eql(`<ul> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <li> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |     <a href="#">a</a> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | </li> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <li> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |     <a href="#">b</a> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | </li> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:33:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <li> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 10:43:12 +08:00
										 |  |  |     <a href="#">c</a> | 
					
						
							| 
									
										
										
										
											2018-03-07 09:33:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | </li> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | </ul>`);
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:21:16 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   it('不要拆解行内的 html tag', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  |     expect(normalizeLines(`
 | 
					
						
							|  |  |  | a <b> c | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | `)).eql(`a <b> c`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 17:47:09 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  |   it('把连续的三行及以上空行简化为两个空行', function () { | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  |     const lines = normalizeLines(`
 | 
					
						
							|  |  |  |   a   | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |     expect(lines).eql(`a  
 | 
					
						
							| 
									
										
										
										
											2018-03-07 09:41:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |  b`);
 | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-06 17:32:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-15 16:40:11 +08:00
										 |  |  |   it('拆分', function () { | 
					
						
							|  |  |  |     expect(tokenize('abc def,abc.')).eql(['abc', 'def', 'abc']); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  |   it('抽取核心字符', function () { | 
					
						
							|  |  |  |     expect(kernelText(' # Forms   ABC. ')).eql('#FORMSABC'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('删除非核心字符', function () { | 
					
						
							|  |  |  |     expect(kernelText('Abc-132-@#!abc')).eql('ABC132#ABC'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-15 16:40:11 +08:00
										 |  |  |   it('模糊匹配', function () { | 
					
						
							|  |  |  |     expect(fuzzyTest(`a b c d e`, `a b c d e`)).is.false; | 
					
						
							|  |  |  |     expect(fuzzyTest(`a b c d e f g`, `a b c d e`)).is.false; | 
					
						
							|  |  |  |     expect(fuzzyTest(`Make that easy by encapsulating the _click-triggering_ process in a helper such as the \`click\` function below:`, | 
					
						
							|  |  |  |       `Make that consistent and easy by encapsulating the _click-triggering_ process 
 | 
					
						
							|  |  |  | in a helper such as the \`click()\` function below:
 | 
					
						
							|  |  |  | `)).is.true;
 | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-24 16:33:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   it('检测是否表格', function () { | 
					
						
							|  |  |  |     expect(hasInlineText(`
 | 
					
						
							|  |  |  | abc | def | 
					
						
							|  |  |  | ----|--- | 
					
						
							|  |  |  | gh  | ij | 
					
						
							|  |  |  | `)).eql(true);
 | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-03-03 11:01:57 +08:00
										 |  |  | }); |