@@ -55,6 +55,81 @@ describe('TodoistApi task endpoints', () => {
5555
5656 expect ( task ) . toEqual ( DEFAULT_TASK )
5757 } )
58+
59+ test ( 'adds uncompletable prefix when isUncompletable is true' , async ( ) => {
60+ const expectedTask = {
61+ ...DEFAULT_TASK ,
62+ content : '* This is an uncompletable task' ,
63+ isUncompletable : true ,
64+ }
65+
66+ server . use (
67+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_REST_TASKS } ` , async ( { request } ) => {
68+ const body = ( await request . json ( ) ) as any
69+ expect ( body . content ) . toBe ( '* This is an uncompletable task' )
70+ return HttpResponse . json ( expectedTask , { status : 200 } )
71+ } ) ,
72+ )
73+ const api = getTarget ( )
74+
75+ const task = await api . addTask ( {
76+ content : 'This is an uncompletable task' ,
77+ isUncompletable : true ,
78+ } )
79+
80+ expect ( task . content ) . toBe ( '* This is an uncompletable task' )
81+ expect ( task . isUncompletable ) . toBe ( true )
82+ } )
83+
84+ test ( 'preserves existing prefix when isUncompletable is false' , async ( ) => {
85+ const expectedTask = {
86+ ...DEFAULT_TASK ,
87+ content : '* Already has prefix' ,
88+ isUncompletable : true ,
89+ }
90+
91+ server . use (
92+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_REST_TASKS } ` , async ( { request } ) => {
93+ const body = ( await request . json ( ) ) as any
94+ expect ( body . content ) . toBe ( '* Already has prefix' )
95+ return HttpResponse . json ( expectedTask , { status : 200 } )
96+ } ) ,
97+ )
98+ const api = getTarget ( )
99+
100+ const task = await api . addTask ( {
101+ content : '* Already has prefix' ,
102+ isUncompletable : false ,
103+ } )
104+
105+ expect ( task . content ) . toBe ( '* Already has prefix' )
106+ expect ( task . isUncompletable ) . toBe ( true )
107+ } )
108+
109+ test ( 'does not add prefix when isUncompletable is false' , async ( ) => {
110+ const expectedTask = {
111+ ...DEFAULT_TASK ,
112+ content : 'Regular completable task' ,
113+ isUncompletable : false ,
114+ }
115+
116+ server . use (
117+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_REST_TASKS } ` , async ( { request } ) => {
118+ const body = ( await request . json ( ) ) as any
119+ expect ( body . content ) . toBe ( 'Regular completable task' )
120+ return HttpResponse . json ( expectedTask , { status : 200 } )
121+ } ) ,
122+ )
123+ const api = getTarget ( )
124+
125+ const task = await api . addTask ( {
126+ content : 'Regular completable task' ,
127+ isUncompletable : false ,
128+ } )
129+
130+ expect ( task . content ) . toBe ( 'Regular completable task' )
131+ expect ( task . isUncompletable ) . toBe ( false )
132+ } )
58133 } )
59134
60135 describe ( 'updateTask' , ( ) => {
@@ -81,6 +156,55 @@ describe('TodoistApi task endpoints', () => {
81156
82157 expect ( response ) . toEqual ( returnedTask )
83158 } )
159+
160+ test ( 'processes content with isUncompletable when both are provided' , async ( ) => {
161+ const returnedTask = {
162+ ...DEFAULT_TASK ,
163+ content : '* Updated uncompletable task' ,
164+ isUncompletable : true ,
165+ url : getTaskUrl ( DEFAULT_TASK_ID , '* Updated uncompletable task' ) ,
166+ }
167+
168+ server . use (
169+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_REST_TASKS } /123` , async ( { request } ) => {
170+ const body = ( await request . json ( ) ) as any
171+ expect ( body . content ) . toBe ( '* Updated uncompletable task' )
172+ return HttpResponse . json ( returnedTask , { status : 200 } )
173+ } ) ,
174+ )
175+ const api = getTarget ( )
176+
177+ const response = await api . updateTask ( '123' , {
178+ content : 'Updated uncompletable task' ,
179+ isUncompletable : true ,
180+ } )
181+
182+ expect ( response . content ) . toBe ( '* Updated uncompletable task' )
183+ expect ( response . isUncompletable ) . toBe ( true )
184+ } )
185+
186+ test ( 'does not process content when only isUncompletable is provided' , async ( ) => {
187+ const returnedTask = {
188+ ...DEFAULT_TASK ,
189+ isUncompletable : false ,
190+ }
191+
192+ server . use (
193+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_REST_TASKS } /123` , async ( { request } ) => {
194+ const body = ( await request . json ( ) ) as any
195+ expect ( body . content ) . toBeUndefined ( )
196+ expect ( body . is_uncompletable ) . toBe ( false ) // Note: snake_case conversion
197+ return HttpResponse . json ( returnedTask , { status : 200 } )
198+ } ) ,
199+ )
200+ const api = getTarget ( )
201+
202+ const response = await api . updateTask ( '123' , {
203+ isUncompletable : false ,
204+ } )
205+
206+ expect ( response . isUncompletable ) . toBe ( false )
207+ } )
84208 } )
85209
86210 describe ( 'closeTask' , ( ) => {
@@ -152,6 +276,56 @@ describe('TodoistApi task endpoints', () => {
152276 const task = await api . quickAddTask ( DEFAULT_QUICK_ADD_ARGS )
153277 expect ( task ) . toEqual ( DEFAULT_TASK )
154278 } )
279+
280+ test ( 'adds uncompletable prefix when isUncompletable is true' , async ( ) => {
281+ const expectedTask = {
282+ ...DEFAULT_TASK ,
283+ content : '* Quick uncompletable task' ,
284+ isUncompletable : true ,
285+ }
286+
287+ server . use (
288+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_SYNC_QUICK_ADD } ` , async ( { request } ) => {
289+ const body = ( await request . json ( ) ) as any
290+ expect ( body . text ) . toBe ( '* Quick uncompletable task' )
291+ return HttpResponse . json ( expectedTask , { status : 200 } )
292+ } ) ,
293+ )
294+ const api = getTarget ( )
295+
296+ const task = await api . quickAddTask ( {
297+ text : 'Quick uncompletable task' ,
298+ isUncompletable : true ,
299+ } )
300+
301+ expect ( task . content ) . toBe ( '* Quick uncompletable task' )
302+ expect ( task . isUncompletable ) . toBe ( true )
303+ } )
304+
305+ test ( 'preserves existing prefix even when isUncompletable is false' , async ( ) => {
306+ const expectedTask = {
307+ ...DEFAULT_TASK ,
308+ content : '* Already prefixed quick task' ,
309+ isUncompletable : true ,
310+ }
311+
312+ server . use (
313+ http . post ( `${ getSyncBaseUri ( ) } ${ ENDPOINT_SYNC_QUICK_ADD } ` , async ( { request } ) => {
314+ const body = ( await request . json ( ) ) as any
315+ expect ( body . text ) . toBe ( '* Already prefixed quick task' )
316+ return HttpResponse . json ( expectedTask , { status : 200 } )
317+ } ) ,
318+ )
319+ const api = getTarget ( )
320+
321+ const task = await api . quickAddTask ( {
322+ text : '* Already prefixed quick task' ,
323+ isUncompletable : false ,
324+ } )
325+
326+ expect ( task . content ) . toBe ( '* Already prefixed quick task' )
327+ expect ( task . isUncompletable ) . toBe ( true )
328+ } )
155329 } )
156330
157331 describe ( 'getTask' , ( ) => {
0 commit comments