@@ -46,6 +46,20 @@ describe('toggleCheckboxAt', () => {
4646 const out = toggleCheckboxAt ( src , 99 , true )
4747 expect ( out . ok ) . toBe ( false )
4848 } )
49+
50+ it ( 'handles CRLF line endings and normalizes to LF' , ( ) => {
51+ const crlf = '- [ ] one\r\n- [x] two\r\n- [ ] three'
52+ const out = toggleCheckboxAt ( crlf , 0 , true )
53+ expect ( out . ok ) . toBe ( true )
54+ if ( out . ok ) expect ( out . value ) . toBe ( '- [x] one\n- [x] two\n- [ ] three' )
55+ } )
56+
57+ it ( 'toggles a middle line in a CRLF document' , ( ) => {
58+ const crlf = '- [ ] one\r\n- [ ] two\r\n- [ ] three'
59+ const out = toggleCheckboxAt ( crlf , 1 , true )
60+ expect ( out . ok ) . toBe ( true )
61+ if ( out . ok ) expect ( out . value . split ( '\n' ) [ 1 ] ) . toBe ( '- [x] two' )
62+ } )
4963} )
5064
5165describe ( 'countActionItems' , ( ) => {
@@ -54,6 +68,10 @@ describe('countActionItems', () => {
5468 expect ( countActionItems ( src ) ) . toEqual ( { done : 2 , total : 4 } )
5569 } )
5670
71+ it ( 'counts CRLF documents' , ( ) => {
72+ expect ( countActionItems ( '- [x] a\r\n- [ ] b\r\n- [x] c' ) ) . toEqual ( { done : 2 , total : 3 } )
73+ } )
74+
5775 it ( 'treats null/empty as zero' , ( ) => {
5876 expect ( countActionItems ( null ) ) . toEqual ( { done : 0 , total : 0 } )
5977 expect ( countActionItems ( '' ) ) . toEqual ( { done : 0 , total : 0 } )
0 commit comments