11import { testing } from './wrap.ts' ;
22const { test, expect } = await testing ;
33import AST from '../src/parser.ts' ;
4- import { getText , syncTag , unParse } from '../src/tags.ts' ;
4+ import { getText , syncTag } from '../src/tags.ts' ;
55
66test ( 'raw text getText' , ( ) => {
77 const txt = ' blah blah...' ;
@@ -19,53 +19,60 @@ test('single tag getText', () => {
1919
2020test ( 'raw text parse unparse' , ( ) => {
2121 const txt = ' blah blah...' ;
22- const ast = new AST ( ) . parse ( txt ) ;
23- const final = unParse ( ast [ 0 ] ) ;
22+ const ast = new AST ( ) ;
23+ ast . parse ( txt ) ;
24+ const final = ast . unParse ( ) ;
2425 expect ( final ) . toBe ( txt ) ;
2526} ) ;
2627
2728test ( 'single tag parse unparse' , ( ) => {
2829 const txt = '<stuff />' ;
29- const ast = new AST ( ) . parse ( txt ) ;
30- const final = unParse ( ast [ 0 ] ) ;
30+ const ast = new AST ( ) ;
31+ ast . parse ( txt ) ;
32+ const final = ast . unParse ( ) ;
3133 expect ( final ) . toBe ( txt ) ;
3234} ) ;
3335
3436test ( 'double tag parse unparse 1' , ( ) => {
3537 const txt = '<stuff></stuff>' ;
36- const ast = new AST ( ) . parse ( txt ) ;
37- const final = unParse ( ast [ 0 ] ) ;
38+ const ast = new AST ( ) ;
39+ ast . parse ( txt ) ;
40+ const final = ast . unParse ( ) ;
3841 expect ( final ) . toBe ( txt ) ;
3942} ) ;
4043
4144test ( 'double tag parse unparse 2' , ( ) => {
4245 const txt = '<stuff>??? </stuff>' ;
43- const ast = new AST ( ) . parse ( txt ) ;
44- const final = unParse ( ast [ 0 ] ) ;
46+ const ast = new AST ( ) ;
47+ ast . parse ( txt ) ;
48+ const final = ast . unParse ( ) ;
4549 expect ( final ) . toBe ( txt ) ;
4650} ) ;
4751
4852test ( 'parse unparse 1' , ( ) => {
4953 let txt = '<mumu a=b><mumu><mumu><text>0</text>' ;
5054 txt += '\n</mumu></mumu></mumu>' ;
51- const ast = new AST ( ) . parse ( txt ) ;
52- const final = unParse ( ast [ 0 ] ) ;
55+ const ast = new AST ( ) ;
56+ ast . parse ( txt ) ;
57+ const final = ast . unParse ( ) ;
5358 expect ( final ) . toBe ( txt ) ;
5459} ) ;
5560
5661test ( 'parse unparse 2' , ( ) => {
5762 let txt = '' ;
5863 txt += '<div><span class="title">Hello</span> <br />\n' ;
5964 txt += '<span class="text">Workd</span> <br />\n</div>' ;
60- const ast = new AST ( ) . parse ( txt ) ;
61- const final = unParse ( ast [ 0 ] ) ;
65+ const ast = new AST ( ) ;
66+ ast . parse ( txt ) ;
67+ const final = ast . unParse ( ) ;
6268 expect ( final ) . toBe ( txt ) ;
6369} ) ;
6470
6571test ( 'parse unparse 3' , ( ) => {
6672 const txt = '<noop>1<noop>2</noop>3</noop>' ;
67- const ast = new AST ( ) . parse ( txt ) ;
68- const final = unParse ( ast [ 0 ] ) ;
73+ const ast = new AST ( ) ;
74+ ast . parse ( txt ) ;
75+ const final = ast . unParse ( ) ;
6976 expect ( final ) . toBe ( txt ) ;
7077} ) ;
7178
0 commit comments