@@ -2,16 +2,8 @@ var parser = require('..');
22var describe = require ( 'mocha' ) . describe ;
33var it = require ( 'mocha' ) . it ;
44var expect = require ( 'chai' ) . expect ;
5- var path = require ( 'path' ) ;
6- var fs = require ( 'fs' ) ;
7- var html = fs . readFileSync ( path . resolve ( __dirname , 'templates/render.html' ) , 'utf8' ) . toString ( ) ;
8- var tree = require ( './templates/parser.js' ) ;
95
106describe ( 'PostHTML-Parser test' , function ( ) {
11- it ( 'html to tree' , function ( ) {
12- expect ( parser ( html ) ) . to . eql ( tree ) ;
13- } ) ;
14-
157 it ( 'should be parse comment' , function ( ) {
168 expect ( parser ( '<!--comment-->' ) ) . to . eql ( [ '<!--comment-->' ] ) ;
179 } ) ;
@@ -45,4 +37,16 @@ describe('PostHTML-Parser test', function() {
4537 it ( 'should be parse text in content' , function ( ) {
4638 expect ( parser ( '<div>Text</div>' ) ) . to . eql ( [ { tag : 'div' , content : [ 'Text' ] } ] ) ;
4739 } ) ;
40+
41+ it ( 'should be parse not a single node in tree' , function ( ) {
42+ expect ( parser ( '<span>Text1</span><span>Text2</span>Text3' ) ) . to . eql ( [
43+ { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3'
44+ ] ) ;
45+ } ) ;
46+
47+ it ( 'should be parse not a single node in parent content' , function ( ) {
48+ expect ( parser ( '<div><span>Text1</span><span>Text2</span>Text3</div>' ) ) . to . eql ( [
49+ { tag : 'div' , content : [ { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3' ] }
50+ ] ) ;
51+ } ) ;
4852} ) ;
0 commit comments