@@ -43,7 +43,7 @@ class TestSelectionService {
4343 }
4444}
4545
46- describe ( 'xterm-addon-serialize html ' , ( ) => {
46+ describe ( 'xterm-addon-serialize' , ( ) => {
4747 let cm : ColorManager ;
4848 let dom : jsdom . JSDOM ;
4949 let document : Document ;
@@ -83,123 +83,132 @@ describe('xterm-addon-serialize html', () => {
8383 ( terminal as any ) . _core . _selectionService = selectionService ;
8484 } ) ;
8585
86- it ( 'empty terminal with selection turned off' , ( ) => {
87- const output = serializeAddon . serializeAsHTML ( ) ;
88- assert . notEqual ( output , '' ) ;
89- assert . equal ( ( output . match ( / < d i v > < s p a n > { 10 } < \/ s p a n > < \/ d i v > / g) || [ ] ) . length , 2 ) ;
86+ describe ( 'text' , ( ) => {
87+ it ( 'restoring cursor styles' , async ( ) => {
88+ await writeP ( terminal , sgr ( '32' ) + '> ' + sgr ( '0' ) ) ;
89+ assert . equal ( serializeAddon . serialize ( ) , '\u001b[32m> \u001b[0m' ) ;
90+ } ) ;
9091 } ) ;
9192
92- it ( 'empty terminal with no selection' , ( ) => {
93- const output = serializeAddon . serializeAsHTML ( {
94- onlySelection : true
93+ describe ( 'html' , ( ) => {
94+ it ( 'empty terminal with selection turned off' , ( ) => {
95+ const output = serializeAddon . serializeAsHTML ( ) ;
96+ assert . notEqual ( output , '' ) ;
97+ assert . equal ( ( output . match ( / < d i v > < s p a n > { 10 } < \/ s p a n > < \/ d i v > / g) || [ ] ) . length , 2 ) ;
98+ } ) ;
99+
100+ it ( 'empty terminal with no selection' , ( ) => {
101+ const output = serializeAddon . serializeAsHTML ( {
102+ onlySelection : true
103+ } ) ;
104+ assert . equal ( output , '' ) ;
95105 } ) ;
96- assert . equal ( output , '' ) ;
97- } ) ;
98106
99- it ( 'basic terminal with selection' , async ( ) => {
100- await writeP ( terminal , ' terminal ' ) ;
101- terminal . select ( 1 , 0 , 8 ) ;
107+ it ( 'basic terminal with selection' , async ( ) => {
108+ await writeP ( terminal , ' terminal ' ) ;
109+ terminal . select ( 1 , 0 , 8 ) ;
102110
103- const output = serializeAddon . serializeAsHTML ( {
104- onlySelection : true
111+ const output = serializeAddon . serializeAsHTML ( {
112+ onlySelection : true
113+ } ) ;
114+ assert . equal ( ( output . match ( / < d i v > < s p a n > t e r m i n a l < \/ s p a n > < \/ d i v > / g) || [ ] ) . length , 1 , output ) ;
105115 } ) ;
106- assert . equal ( ( output . match ( / < d i v > < s p a n > t e r m i n a l < \/ s p a n > < \/ d i v > / g) || [ ] ) . length , 1 , output ) ;
107- } ) ;
108116
109- it ( 'cells with bold styling' , async ( ) => {
110- await writeP ( terminal , ' ' + sgr ( '1' ) + 'terminal' + sgr ( '22' ) + ' ' ) ;
117+ it ( 'cells with bold styling' , async ( ) => {
118+ await writeP ( terminal , ' ' + sgr ( '1' ) + 'terminal' + sgr ( '22' ) + ' ' ) ;
111119
112- const output = serializeAddon . serializeAsHTML ( ) ;
113- assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
114- } ) ;
120+ const output = serializeAddon . serializeAsHTML ( ) ;
121+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
122+ } ) ;
115123
116- it ( 'cells with italic styling' , async ( ) => {
117- await writeP ( terminal , ' ' + sgr ( '3' ) + 'terminal' + sgr ( '23' ) + ' ' ) ;
124+ it ( 'cells with italic styling' , async ( ) => {
125+ await writeP ( terminal , ' ' + sgr ( '3' ) + 'terminal' + sgr ( '23' ) + ' ' ) ;
118126
119- const output = serializeAddon . serializeAsHTML ( ) ;
120- assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - s t y l e : i t a l i c ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
121- } ) ;
127+ const output = serializeAddon . serializeAsHTML ( ) ;
128+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - s t y l e : i t a l i c ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
129+ } ) ;
122130
123- it ( 'cells with inverse styling' , async ( ) => {
124- await writeP ( terminal , ' ' + sgr ( '7' ) + 'terminal' + sgr ( '27' ) + ' ' ) ;
131+ it ( 'cells with inverse styling' , async ( ) => {
132+ await writeP ( terminal , ' ' + sgr ( '7' ) + 'terminal' + sgr ( '27' ) + ' ' ) ;
125133
126- const output = serializeAddon . serializeAsHTML ( ) ;
127- assert . equal ( ( output . match ( / < s p a n s t y l e = ' c o l o r : # 0 0 0 0 0 0 ; b a c k g r o u n d - c o l o r : # B F B F B F ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
128- } ) ;
134+ const output = serializeAddon . serializeAsHTML ( ) ;
135+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' c o l o r : # 0 0 0 0 0 0 ; b a c k g r o u n d - c o l o r : # B F B F B F ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
136+ } ) ;
129137
130- it ( 'cells with underline styling' , async ( ) => {
131- await writeP ( terminal , ' ' + sgr ( '4' ) + 'terminal' + sgr ( '24' ) + ' ' ) ;
138+ it ( 'cells with underline styling' , async ( ) => {
139+ await writeP ( terminal , ' ' + sgr ( '4' ) + 'terminal' + sgr ( '24' ) + ' ' ) ;
132140
133- const output = serializeAddon . serializeAsHTML ( ) ;
134- assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : u n d e r l i n e ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
135- } ) ;
141+ const output = serializeAddon . serializeAsHTML ( ) ;
142+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : u n d e r l i n e ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
143+ } ) ;
136144
137- it ( 'cells with invisible styling' , async ( ) => {
138- await writeP ( terminal , ' ' + sgr ( '8' ) + 'terminal' + sgr ( '28' ) + ' ' ) ;
145+ it ( 'cells with invisible styling' , async ( ) => {
146+ await writeP ( terminal , ' ' + sgr ( '8' ) + 'terminal' + sgr ( '28' ) + ' ' ) ;
139147
140- const output = serializeAddon . serializeAsHTML ( ) ;
141- assert . equal ( ( output . match ( / < s p a n s t y l e = ' v i s i b i l i t y : h i d d e n ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
142- } ) ;
148+ const output = serializeAddon . serializeAsHTML ( ) ;
149+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' v i s i b i l i t y : h i d d e n ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
150+ } ) ;
143151
144- it ( 'cells with dim styling' , async ( ) => {
145- await writeP ( terminal , ' ' + sgr ( '2' ) + 'terminal' + sgr ( '22' ) + ' ' ) ;
152+ it ( 'cells with dim styling' , async ( ) => {
153+ await writeP ( terminal , ' ' + sgr ( '2' ) + 'terminal' + sgr ( '22' ) + ' ' ) ;
146154
147- const output = serializeAddon . serializeAsHTML ( ) ;
148- assert . equal ( ( output . match ( / < s p a n s t y l e = ' o p a c i t y : 0 .5 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
149- } ) ;
155+ const output = serializeAddon . serializeAsHTML ( ) ;
156+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' o p a c i t y : 0 .5 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
157+ } ) ;
150158
151- it ( 'cells with strikethrough styling' , async ( ) => {
152- await writeP ( terminal , ' ' + sgr ( '9' ) + 'terminal' + sgr ( '29' ) + ' ' ) ;
159+ it ( 'cells with strikethrough styling' , async ( ) => {
160+ await writeP ( terminal , ' ' + sgr ( '9' ) + 'terminal' + sgr ( '29' ) + ' ' ) ;
153161
154- const output = serializeAddon . serializeAsHTML ( ) ;
155- assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
156- } ) ;
162+ const output = serializeAddon . serializeAsHTML ( ) ;
163+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
164+ } ) ;
157165
158- it ( 'cells with combined styling' , async ( ) => {
159- await writeP ( terminal , sgr ( '1' ) + ' ' + sgr ( '9' ) + 'termi' + sgr ( '22' ) + 'nal' + sgr ( '29' ) + ' ' ) ;
166+ it ( 'cells with combined styling' , async ( ) => {
167+ await writeP ( terminal , sgr ( '1' ) + ' ' + sgr ( '9' ) + 'termi' + sgr ( '22' ) + 'nal' + sgr ( '29' ) + ' ' ) ;
160168
161- const output = serializeAddon . serializeAsHTML ( ) ;
162- assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; ' > < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
163- assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > t e r m i < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
164- assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
165- } ) ;
169+ const output = serializeAddon . serializeAsHTML ( ) ;
170+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; ' > < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
171+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' f o n t - w e i g h t : b o l d ; t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > t e r m i < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
172+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' t e x t - d e c o r a t i o n : l i n e - t h r o u g h ; ' > n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
173+ } ) ;
166174
167- it ( 'cells with color styling' , async ( ) => {
168- await writeP ( terminal , ' ' + sgr ( '38;5;46' ) + 'terminal' + sgr ( '39' ) + ' ' ) ;
175+ it ( 'cells with color styling' , async ( ) => {
176+ await writeP ( terminal , ' ' + sgr ( '38;5;46' ) + 'terminal' + sgr ( '39' ) + ' ' ) ;
169177
170- const output = serializeAddon . serializeAsHTML ( ) ;
171- assert . equal ( ( output . match ( / < s p a n s t y l e = ' c o l o r : # 0 0 f f 0 0 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
172- } ) ;
178+ const output = serializeAddon . serializeAsHTML ( ) ;
179+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' c o l o r : # 0 0 f f 0 0 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
180+ } ) ;
173181
174- it ( 'cells with background styling' , async ( ) => {
175- await writeP ( terminal , ' ' + sgr ( '48;5;46' ) + 'terminal' + sgr ( '49' ) + ' ' ) ;
182+ it ( 'cells with background styling' , async ( ) => {
183+ await writeP ( terminal , ' ' + sgr ( '48;5;46' ) + 'terminal' + sgr ( '49' ) + ' ' ) ;
176184
177- const output = serializeAddon . serializeAsHTML ( ) ;
178- assert . equal ( ( output . match ( / < s p a n s t y l e = ' b a c k g r o u n d - c o l o r : # 0 0 f f 0 0 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
179- } ) ;
185+ const output = serializeAddon . serializeAsHTML ( ) ;
186+ assert . equal ( ( output . match ( / < s p a n s t y l e = ' b a c k g r o u n d - c o l o r : # 0 0 f f 0 0 ; ' > t e r m i n a l < \/ s p a n > / g) || [ ] ) . length , 1 , output ) ;
187+ } ) ;
180188
181- it ( 'empty terminal with default options' , async ( ) => {
182- const output = serializeAddon . serializeAsHTML ( ) ;
183- assert . equal ( ( output . match ( / c o l o r : # 0 0 0 0 0 0 ; b a c k g r o u n d - c o l o r : # f f f f f f ; f o n t - f a m i l y : c o u r i e r - n e w , c o u r i e r , m o n o s p a c e ; f o n t - s i z e : 1 5 p x ; / g) || [ ] ) . length , 1 , output ) ;
184- } ) ;
189+ it ( 'empty terminal with default options' , async ( ) => {
190+ const output = serializeAddon . serializeAsHTML ( ) ;
191+ assert . equal ( ( output . match ( / c o l o r : # 0 0 0 0 0 0 ; b a c k g r o u n d - c o l o r : # f f f f f f ; f o n t - f a m i l y : c o u r i e r - n e w , c o u r i e r , m o n o s p a c e ; f o n t - s i z e : 1 5 p x ; / g) || [ ] ) . length , 1 , output ) ;
192+ } ) ;
185193
186- it ( 'empty terminal with custom options' , async ( ) => {
187- terminal . options . fontFamily = 'verdana' ;
188- terminal . options . fontSize = 20 ;
189- terminal . options . theme = {
190- foreground : '#ff00ff' ,
191- background : '#00ff00'
192- } ;
193- const output = serializeAddon . serializeAsHTML ( {
194- includeGlobalBackground : true
195- } ) ;
196- assert . equal ( ( output . match ( / c o l o r : # f f 0 0 f f ; b a c k g r o u n d - c o l o r : # 0 0 f f 0 0 ; f o n t - f a m i l y : v e r d a n a ; f o n t - s i z e : 2 0 p x ; / g) || [ ] ) . length , 1 , output ) ;
197- } ) ;
194+ it ( 'empty terminal with custom options' , async ( ) => {
195+ terminal . options . fontFamily = 'verdana' ;
196+ terminal . options . fontSize = 20 ;
197+ terminal . options . theme = {
198+ foreground : '#ff00ff' ,
199+ background : '#00ff00'
200+ } ;
201+ const output = serializeAddon . serializeAsHTML ( {
202+ includeGlobalBackground : true
203+ } ) ;
204+ assert . equal ( ( output . match ( / c o l o r : # f f 0 0 f f ; b a c k g r o u n d - c o l o r : # 0 0 f f 0 0 ; f o n t - f a m i l y : v e r d a n a ; f o n t - s i z e : 2 0 p x ; / g) || [ ] ) . length , 1 , output ) ;
205+ } ) ;
198206
199- it ( 'empty terminal with background included' , async ( ) => {
200- const output = serializeAddon . serializeAsHTML ( {
201- includeGlobalBackground : true
207+ it ( 'empty terminal with background included' , async ( ) => {
208+ const output = serializeAddon . serializeAsHTML ( {
209+ includeGlobalBackground : true
210+ } ) ;
211+ assert . equal ( ( output . match ( / c o l o r : # f f f f f f ; b a c k g r o u n d - c o l o r : # 0 0 0 0 0 0 ; f o n t - f a m i l y : c o u r i e r - n e w , c o u r i e r , m o n o s p a c e ; f o n t - s i z e : 1 5 p x ; / g) || [ ] ) . length , 1 , output ) ;
202212 } ) ;
203- assert . equal ( ( output . match ( / c o l o r : # f f f f f f ; b a c k g r o u n d - c o l o r : # 0 0 0 0 0 0 ; f o n t - f a m i l y : c o u r i e r - n e w , c o u r i e r , m o n o s p a c e ; f o n t - s i z e : 1 5 p x ; / g) || [ ] ) . length , 1 , output ) ;
204213 } ) ;
205214} ) ;
0 commit comments