@@ -56,27 +56,27 @@ describe('ansi', () => {
5656
5757 it ( 'should match ANSI reset code' , ( ) => {
5858 const regex = ansiRegex ( )
59- const text = ` \x1b[0mPlain text`
59+ const text = ' \x1b[0mPlain text'
6060 expect ( regex . test ( text ) ) . toBe ( true )
6161 } )
6262
6363 it ( 'should match ANSI color codes' , ( ) => {
6464 const regex = ansiRegex ( )
65- const text = ` \x1b[31mRed text\x1b[0m`
65+ const text = ' \x1b[31mRed text\x1b[0m'
6666 expect ( regex . test ( text ) ) . toBe ( true )
6767 } )
6868
6969 it ( 'should match multiple ANSI codes' , ( ) => {
7070 const regex = ansiRegex ( )
71- const text = ` \x1b[1m\x1b[31mBold red\x1b[0m`
71+ const text = ' \x1b[1m\x1b[31mBold red\x1b[0m'
7272 const matches = text . match ( regex )
7373 expect ( matches ) . not . toBeNull ( )
7474 expect ( matches ?. length ) . toBeGreaterThanOrEqual ( 2 )
7575 } )
7676
7777 it ( 'should match CSI sequences' , ( ) => {
7878 const regex = ansiRegex ( )
79- const text = ` \x1b[2J\x1b[H`
79+ const text = ' \x1b[2J\x1b[H'
8080 expect ( regex . test ( text ) ) . toBe ( true )
8181 } )
8282
@@ -93,7 +93,7 @@ describe('ansi', () => {
9393
9494 it ( 'should create non-global regex when onlyFirst is true' , ( ) => {
9595 const regex = ansiRegex ( { onlyFirst : true } )
96- const text = ` \x1b[31mRed\x1b[0m`
96+ const text = ' \x1b[31mRed\x1b[0m'
9797 const match = text . match ( regex )
9898 expect ( match ) . not . toBeNull ( )
9999 expect ( match ?. [ 0 ] ) . toBe ( '\x1b[31m' )
@@ -102,17 +102,17 @@ describe('ansi', () => {
102102
103103 describe ( 'stripAnsi' , ( ) => {
104104 it ( 'should strip ANSI codes from text' , ( ) => {
105- const text = ` \x1b[31mRed text\x1b[0m`
105+ const text = ' \x1b[31mRed text\x1b[0m'
106106 expect ( stripAnsi ( text ) ) . toBe ( 'Red text' )
107107 } )
108108
109109 it ( 'should strip bold formatting' , ( ) => {
110- const text = ` \x1b[1mBold text\x1b[0m`
110+ const text = ' \x1b[1mBold text\x1b[0m'
111111 expect ( stripAnsi ( text ) ) . toBe ( 'Bold text' )
112112 } )
113113
114114 it ( 'should strip multiple ANSI codes' , ( ) => {
115- const text = ` \x1b[1m\x1b[31mBold red\x1b[0m`
115+ const text = ' \x1b[1m\x1b[31mBold red\x1b[0m'
116116 expect ( stripAnsi ( text ) ) . toBe ( 'Bold red' )
117117 } )
118118
@@ -126,52 +126,52 @@ describe('ansi', () => {
126126 } )
127127
128128 it ( 'should strip color codes' , ( ) => {
129- const text = ` \x1b[31mRed\x1b[32mGreen\x1b[34mBlue\x1b[0m`
129+ const text = ' \x1b[31mRed\x1b[32mGreen\x1b[34mBlue\x1b[0m'
130130 expect ( stripAnsi ( text ) ) . toBe ( 'RedGreenBlue' )
131131 } )
132132
133133 it ( 'should strip underline and italic' , ( ) => {
134- const text = ` \x1b[3m\x1b[4mUnderlined Italic\x1b[0m`
134+ const text = ' \x1b[3m\x1b[4mUnderlined Italic\x1b[0m'
135135 expect ( stripAnsi ( text ) ) . toBe ( 'Underlined Italic' )
136136 } )
137137
138138 it ( 'should strip background colors' , ( ) => {
139- const text = ` \x1b[41mRed background\x1b[0m`
139+ const text = ' \x1b[41mRed background\x1b[0m'
140140 expect ( stripAnsi ( text ) ) . toBe ( 'Red background' )
141141 } )
142142
143143 it ( 'should strip 256 color codes' , ( ) => {
144- const text = ` \x1b[38;5;196mBright red\x1b[0m`
144+ const text = ' \x1b[38;5;196mBright red\x1b[0m'
145145 expect ( stripAnsi ( text ) ) . toBe ( 'Bright red' )
146146 } )
147147
148148 it ( 'should strip RGB color codes' , ( ) => {
149- const text = ` \x1b[38;2;255;0;0mRGB red\x1b[0m`
149+ const text = ' \x1b[38;2;255;0;0mRGB red\x1b[0m'
150150 expect ( stripAnsi ( text ) ) . toBe ( 'RGB red' )
151151 } )
152152
153153 it ( 'should handle text with only ANSI codes' , ( ) => {
154- const text = ` \x1b[31m\x1b[1m\x1b[0m`
154+ const text = ' \x1b[31m\x1b[1m\x1b[0m'
155155 expect ( stripAnsi ( text ) ) . toBe ( '' )
156156 } )
157157
158158 it ( 'should handle mixed content' , ( ) => {
159- const text = ` Normal \x1b[1mbold\x1b[0m normal \x1b[31mred\x1b[0m end`
159+ const text = ' Normal \x1b[1mbold\x1b[0m normal \x1b[31mred\x1b[0m end'
160160 expect ( stripAnsi ( text ) ) . toBe ( 'Normal bold normal red end' )
161161 } )
162162
163163 it ( 'should handle newlines and special chars' , ( ) => {
164- const text = ` \x1b[31mLine 1\nLine 2\x1b[0m`
164+ const text = ' \x1b[31mLine 1\nLine 2\x1b[0m'
165165 expect ( stripAnsi ( text ) ) . toBe ( 'Line 1\nLine 2' )
166166 } )
167167
168168 it ( 'should handle unicode characters' , ( ) => {
169- const text = ` \x1b[31m你好世界\x1b[0m`
169+ const text = ' \x1b[31m你好世界\x1b[0m'
170170 expect ( stripAnsi ( text ) ) . toBe ( '你好世界' )
171171 } )
172172
173173 it ( 'should handle emojis' , ( ) => {
174- const text = ` \x1b[32m✓\x1b[0m Success`
174+ const text = ' \x1b[32m✓\x1b[0m Success'
175175 expect ( stripAnsi ( text ) ) . toBe ( '✓ Success' )
176176 } )
177177 } )
@@ -220,18 +220,18 @@ describe('ansi', () => {
220220 } )
221221
222222 it ( 'should handle very long strings' , ( ) => {
223- const longText = 'a' . repeat ( 10000 )
223+ const longText = 'a' . repeat ( 10_000 )
224224 const formatted = `\x1b[31m${ longText } \x1b[0m`
225225 expect ( stripAnsi ( formatted ) ) . toBe ( longText )
226226 } )
227227
228228 it ( 'should handle nested ANSI codes' , ( ) => {
229- const text = ` \x1b[31m\x1b[1mNested\x1b[0m\x1b[0m`
229+ const text = ' \x1b[31m\x1b[1mNested\x1b[0m\x1b[0m'
230230 expect ( stripAnsi ( text ) ) . toBe ( 'Nested' )
231231 } )
232232
233233 it ( 'should handle repeated reset codes' , ( ) => {
234- const text = ` \x1b[31mRed\x1b[0m\x1b[0m\x1b[0m`
234+ const text = ' \x1b[31mRed\x1b[0m\x1b[0m\x1b[0m'
235235 expect ( stripAnsi ( text ) ) . toBe ( 'Red' )
236236 } )
237237 } )
0 commit comments