@@ -10,7 +10,7 @@ import { DateParser } from '../src/Query/DateParser';
10
10
import { QueryLayoutOptions } from '../src/QueryLayoutOptions' ;
11
11
import type { Task } from '../src/Task' ;
12
12
import { TaskRegularExpressions } from '../src/Task' ;
13
- import type { TaskLayoutComponent } from '../src/TaskLayout' ;
13
+ import { type TaskLayoutComponent , taskLayoutComponents } from '../src/TaskLayout' ;
14
14
import type { TextRenderer } from '../src/TaskLineRenderer' ;
15
15
import { TaskLineRenderer } from '../src/TaskLineRenderer' ;
16
16
import { fromLine } from './TestHelpers' ;
@@ -176,12 +176,23 @@ describe('task line rendering - global filter', () => {
176
176
} ) ;
177
177
178
178
describe ( 'task line rendering - layout options' , ( ) => {
179
- const testLayoutOptions = async ( expectedComponents : string [ ] , hiddenComponents : TaskLayoutComponent [ ] ) => {
179
+ const testLayoutOptions = async ( expectedComponents : string [ ] , shownComponents : TaskLayoutComponent [ ] ) => {
180
180
const task = TaskBuilder . createFullyPopulatedTask ( ) ;
181
181
const taskLayoutOptions = new TaskLayoutOptions ( ) ;
182
- hiddenComponents . forEach ( ( hiddenComponent ) => {
183
- taskLayoutOptions . hide ( hiddenComponent ) ;
182
+
183
+ // Hide every layout component:
184
+ taskLayoutComponents . forEach ( ( component ) => {
185
+ taskLayoutOptions . hide ( component ) ;
184
186
} ) ;
187
+
188
+ // Re-enable description
189
+ taskLayoutOptions . setVisibility ( 'description' , true ) ;
190
+
191
+ // Re-enable the requested components:
192
+ shownComponents . forEach ( ( hiddenComponent ) => {
193
+ taskLayoutOptions . setVisibility ( hiddenComponent , true ) ;
194
+ } ) ;
195
+
185
196
const listItem = await renderListItem ( task , taskLayoutOptions ) ;
186
197
const renderedComponents = getListItemComponents ( listItem ) ;
187
198
expect ( renderedComponents ) . toEqual ( expectedComponents ) ;
@@ -203,122 +214,32 @@ describe('task line rendering - layout options', () => {
203
214
' π abcdef' ,
204
215
' ^dcf64c' ,
205
216
] ,
206
- [ ] ,
217
+ taskLayoutComponents ,
207
218
) ;
208
219
} ) ;
209
220
210
- it ( 'renders without priority' , async ( ) => {
211
- await testLayoutOptions (
212
- [
213
- 'Do exercises #todo #health' ,
214
- ' π every day when done' ,
215
- ' β 2023-07-01' ,
216
- ' π« 2023-07-02' ,
217
- ' β³ 2023-07-03' ,
218
- ' π
2023-07-04' ,
219
- ' β 2023-07-06' ,
220
- ' β
2023-07-05' ,
221
- ' βοΈ 123456,abc123' ,
222
- ' π abcdef' ,
223
- ' ^dcf64c' ,
224
- ] ,
225
- [ 'priority' ] ,
226
- ) ;
221
+ it ( 'renders with priority' , async ( ) => {
222
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' πΌ' ] , [ 'priority' ] ) ;
227
223
} ) ;
228
224
229
- it ( 'renders without recurrence rule' , async ( ) => {
230
- await testLayoutOptions (
231
- [
232
- 'Do exercises #todo #health' ,
233
- ' πΌ' ,
234
- ' β 2023-07-01' ,
235
- ' π« 2023-07-02' ,
236
- ' β³ 2023-07-03' ,
237
- ' π
2023-07-04' ,
238
- ' β 2023-07-06' ,
239
- ' β
2023-07-05' ,
240
- ' βοΈ 123456,abc123' ,
241
- ' π abcdef' ,
242
- ' ^dcf64c' ,
243
- ] ,
244
- [ 'recurrenceRule' ] ,
245
- ) ;
225
+ it ( 'renders with recurrence rule' , async ( ) => {
226
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' π every day when done' ] , [ 'recurrenceRule' ] ) ;
246
227
} ) ;
247
228
248
- it ( 'renders without created date' , async ( ) => {
249
- await testLayoutOptions (
250
- [
251
- 'Do exercises #todo #health' ,
252
- ' πΌ' ,
253
- ' π every day when done' ,
254
- ' π« 2023-07-02' ,
255
- ' β³ 2023-07-03' ,
256
- ' π
2023-07-04' ,
257
- ' β 2023-07-06' ,
258
- ' β
2023-07-05' ,
259
- ' βοΈ 123456,abc123' ,
260
- ' π abcdef' ,
261
- ' ^dcf64c' ,
262
- ] ,
263
- [ 'createdDate' ] ,
264
- ) ;
229
+ it ( 'renders with created date' , async ( ) => {
230
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' β 2023-07-01' ] , [ 'createdDate' ] ) ;
265
231
} ) ;
266
232
267
- it ( 'renders without start date' , async ( ) => {
268
- await testLayoutOptions (
269
- [
270
- 'Do exercises #todo #health' ,
271
- ' πΌ' ,
272
- ' π every day when done' ,
273
- ' β 2023-07-01' ,
274
- ' β³ 2023-07-03' ,
275
- ' π
2023-07-04' ,
276
- ' β 2023-07-06' ,
277
- ' β
2023-07-05' ,
278
- ' βοΈ 123456,abc123' ,
279
- ' π abcdef' ,
280
- ' ^dcf64c' ,
281
- ] ,
282
- [ 'startDate' ] ,
283
- ) ;
233
+ it ( 'renders with start date' , async ( ) => {
234
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' π« 2023-07-02' ] , [ 'startDate' ] ) ;
284
235
} ) ;
285
236
286
- it ( 'renders without scheduled date' , async ( ) => {
287
- await testLayoutOptions (
288
- [
289
- 'Do exercises #todo #health' ,
290
- ' πΌ' ,
291
- ' π every day when done' ,
292
- ' β 2023-07-01' ,
293
- ' π« 2023-07-02' ,
294
- ' π
2023-07-04' ,
295
- ' β 2023-07-06' ,
296
- ' β
2023-07-05' ,
297
- ' βοΈ 123456,abc123' ,
298
- ' π abcdef' ,
299
- ' ^dcf64c' ,
300
- ] ,
301
- [ 'scheduledDate' ] ,
302
- ) ;
237
+ it ( 'renders with scheduled date' , async ( ) => {
238
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' β³ 2023-07-03' ] , [ 'scheduledDate' ] ) ;
303
239
} ) ;
304
240
305
- it ( 'renders without due date' , async ( ) => {
306
- await testLayoutOptions (
307
- [
308
- 'Do exercises #todo #health' ,
309
- ' πΌ' ,
310
- ' π every day when done' ,
311
- ' β 2023-07-01' ,
312
- ' π« 2023-07-02' ,
313
- ' β³ 2023-07-03' ,
314
- ' β 2023-07-06' ,
315
- ' β
2023-07-05' ,
316
- ' βοΈ 123456,abc123' ,
317
- ' π abcdef' ,
318
- ' ^dcf64c' ,
319
- ] ,
320
- [ 'dueDate' ] ,
321
- ) ;
241
+ it ( 'renders with due date' , async ( ) => {
242
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' π
2023-07-04' ] , [ 'dueDate' ] ) ;
322
243
} ) ;
323
244
324
245
it ( 'renders a done task correctly with the default layout' , async ( ) => {
@@ -337,84 +258,24 @@ describe('task line rendering - layout options', () => {
337
258
' π abcdef' ,
338
259
' ^dcf64c' ,
339
260
] ,
340
- [ ] ,
261
+ taskLayoutComponents ,
341
262
) ;
342
263
} ) ;
343
264
344
- it ( 'renders without done date' , async ( ) => {
345
- await testLayoutOptions (
346
- [
347
- 'Do exercises #todo #health' ,
348
- ' πΌ' ,
349
- ' π every day when done' ,
350
- ' β 2023-07-01' ,
351
- ' π« 2023-07-02' ,
352
- ' β³ 2023-07-03' ,
353
- ' π
2023-07-04' ,
354
- ' β 2023-07-06' ,
355
- ' βοΈ 123456,abc123' ,
356
- ' π abcdef' ,
357
- ' ^dcf64c' ,
358
- ] ,
359
- [ 'doneDate' ] ,
360
- ) ;
265
+ it ( 'renders with done date' , async ( ) => {
266
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' β
2023-07-05' ] , [ 'doneDate' ] ) ;
361
267
} ) ;
362
268
363
- it ( 'renders without cancelled date' , async ( ) => {
364
- await testLayoutOptions (
365
- [
366
- 'Do exercises #todo #health' ,
367
- ' πΌ' ,
368
- ' π every day when done' ,
369
- ' β 2023-07-01' ,
370
- ' π« 2023-07-02' ,
371
- ' β³ 2023-07-03' ,
372
- ' π
2023-07-04' ,
373
- ' β
2023-07-05' ,
374
- ' βοΈ 123456,abc123' ,
375
- ' π abcdef' ,
376
- ' ^dcf64c' ,
377
- ] ,
378
- [ 'cancelledDate' ] ,
379
- ) ;
269
+ it ( 'renders with cancelled date' , async ( ) => {
270
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' β 2023-07-06' ] , [ 'cancelledDate' ] ) ;
380
271
} ) ;
381
272
382
- it ( 'renders without id' , async ( ) => {
383
- await testLayoutOptions (
384
- [
385
- 'Do exercises #todo #health' ,
386
- ' πΌ' ,
387
- ' π every day when done' ,
388
- ' β 2023-07-01' ,
389
- ' π« 2023-07-02' ,
390
- ' β³ 2023-07-03' ,
391
- ' π
2023-07-04' ,
392
- ' β 2023-07-06' ,
393
- ' β
2023-07-05' ,
394
- ' βοΈ 123456,abc123' ,
395
- ' ^dcf64c' ,
396
- ] ,
397
- [ 'id' ] ,
398
- ) ;
273
+ it ( 'renders with id' , async ( ) => {
274
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' π abcdef' ] , [ 'id' ] ) ;
399
275
} ) ;
400
276
401
- it ( 'renders without depends on' , async ( ) => {
402
- await testLayoutOptions (
403
- [
404
- 'Do exercises #todo #health' ,
405
- ' πΌ' ,
406
- ' π every day when done' ,
407
- ' β 2023-07-01' ,
408
- ' π« 2023-07-02' ,
409
- ' β³ 2023-07-03' ,
410
- ' π
2023-07-04' ,
411
- ' β 2023-07-06' ,
412
- ' β
2023-07-05' ,
413
- ' π abcdef' ,
414
- ' ^dcf64c' ,
415
- ] ,
416
- [ 'blockedBy' ] ,
417
- ) ;
277
+ it ( 'renders with depends on' , async ( ) => {
278
+ await testLayoutOptions ( [ 'Do exercises #todo #health' , ' βοΈ 123456,abc123' ] , [ 'blockedBy' ] ) ;
418
279
} ) ;
419
280
420
281
const testLayoutOptionsFromLine = async ( taskLine : string , expectedComponents : string [ ] ) => {
0 commit comments