@@ -109,6 +109,41 @@ describe('single overlap', () => {
109109 { type : 'emoji' , start : 4 , length : 2 } ,
110110 ] ) ;
111111 } ) ;
112+
113+ test ( 'bold with emoji in the middle' , ( ) => {
114+ let markdownRanges : MarkdownRange [ ] = [
115+ { type : 'bold' , start : 0 , length : 10 } ,
116+ { type : 'emoji' , start : 3 , length : 2 } ,
117+ ] ;
118+
119+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'bold' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
120+ sortRanges ( markdownRanges ) ;
121+
122+ expect ( markdownRanges ) . toEqual ( [
123+ { type : 'bold' , start : 0 , length : 3 } ,
124+ { type : 'emoji' , start : 3 , length : 2 } ,
125+ { type : 'bold' , start : 5 , length : 5 } ,
126+ ] ) ;
127+ } ) ;
128+
129+ test ( 'bold with multiple emojis' , ( ) => {
130+ let markdownRanges : MarkdownRange [ ] = [
131+ { type : 'bold' , start : 0 , length : 10 } ,
132+ { type : 'emoji' , start : 2 , length : 2 } ,
133+ { type : 'emoji' , start : 6 , length : 2 } ,
134+ ] ;
135+
136+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'bold' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
137+ sortRanges ( markdownRanges ) ;
138+
139+ expect ( markdownRanges ) . toEqual ( [
140+ { type : 'bold' , start : 0 , length : 2 } ,
141+ { type : 'emoji' , start : 2 , length : 2 } ,
142+ { type : 'bold' , start : 4 , length : 2 } ,
143+ { type : 'emoji' , start : 6 , length : 2 } ,
144+ { type : 'bold' , start : 8 , length : 2 } ,
145+ ] ) ;
146+ } ) ;
112147} ) ;
113148
114149describe ( 'multiple overlaps' , ( ) => {
@@ -160,4 +195,47 @@ describe('multiple overlaps', () => {
160195 { type : 'strikethrough' , start : 22 , length : 5 } ,
161196 ] ) ;
162197 } ) ;
198+
199+ test ( 'splitting on three types' , ( ) => {
200+ let markdownRanges : MarkdownRange [ ] = [
201+ { type : 'italic' , start : 0 , length : 20 } ,
202+ { type : 'bold' , start : 2 , length : 12 } ,
203+ { type : 'strikethrough' , start : 4 , length : 8 } ,
204+ { type : 'emoji' , start : 6 , length : 2 } ,
205+ ] ;
206+
207+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'italic' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
208+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'bold' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
209+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'strikethrough' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
210+ sortRanges ( markdownRanges ) ;
211+
212+ expect ( markdownRanges ) . toEqual ( [
213+ { type : 'italic' , start : 0 , length : 6 } ,
214+ { type : 'bold' , start : 2 , length : 4 } ,
215+ { type : 'strikethrough' , start : 4 , length : 2 } ,
216+ { type : 'emoji' , start : 6 , length : 2 } ,
217+ { type : 'italic' , start : 8 , length : 12 } ,
218+ { type : 'bold' , start : 8 , length : 6 } ,
219+ { type : 'strikethrough' , start : 8 , length : 4 } ,
220+ ] ) ;
221+ } ) ;
222+
223+ test ( 'nested ranges with emoji' , ( ) => {
224+ let markdownRanges : MarkdownRange [ ] = [
225+ { type : 'italic' , start : 1 , length : 15 } ,
226+ { type : 'bold' , start : 5 , length : 7 } ,
227+ { type : 'emoji' , start : 10 , length : 2 } ,
228+ ] ;
229+
230+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'italic' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
231+ markdownRanges = excludeRangeTypesFromFormatting ( markdownRanges , 'bold' , getRangesToExcludeFormatting ( markdownRanges ) ) ;
232+ sortRanges ( markdownRanges ) ;
233+
234+ expect ( markdownRanges ) . toEqual ( [
235+ { type : 'italic' , start : 1 , length : 9 } ,
236+ { type : 'bold' , start : 5 , length : 5 } ,
237+ { type : 'emoji' , start : 10 , length : 2 } ,
238+ { type : 'italic' , start : 12 , length : 4 } ,
239+ ] ) ;
240+ } ) ;
163241} ) ;
0 commit comments