@@ -364,6 +364,7 @@ describe('task line rendering - classes and data attributes', () => {
364
364
365
365
it ( 'should render date component with its class and data attribute with "today" value' , async ( ) => {
366
366
const today = DateParser . parseDate ( 'today' ) . format ( TaskRegularExpressions . dateFormat ) ;
367
+ // This test ensures that all date fields are handled correctly.
367
368
await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ today } ` , 'task-created' , 'taskCreated: today' ) ;
368
369
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ today } ` , 'task-due' , 'taskDue: today' ) ;
369
370
await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ today } ` , 'task-scheduled' , 'taskScheduled: today' ) ;
@@ -372,64 +373,36 @@ describe('task line rendering - classes and data attributes', () => {
372
373
await testComponentClasses ( `- [-] Canc task ❌ ${ today } ` , 'task-cancelled' , 'taskCancelled: today' ) ;
373
374
} ) ;
374
375
376
+ // Now that we know that 'today' is correctly added to all date fields, the remaining tests
377
+ // only need to test a single date field.
375
378
it ( 'should render date component with its class and data attribute with "future-1d" value' , async ( ) => {
376
379
const future = DateParser . parseDate ( 'tomorrow' ) . format ( TaskRegularExpressions . dateFormat ) ;
377
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ future } ` , 'task-created' , 'taskCreated: future-1d' ) ;
378
380
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ future } ` , 'task-due' , 'taskDue: future-1d' ) ;
379
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ future } ` , 'task-scheduled' , 'taskScheduled: future-1d' ) ;
380
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ future } ` , 'task-start' , 'taskStart: future-1d' ) ;
381
- await testComponentClasses ( `- [x] Done task ✅ ${ future } ` , 'task-done' , 'taskDone: future-1d' ) ;
382
- await testComponentClasses ( `- [-] Canc task ❌ ${ future } ` , 'task-cancelled' , 'taskCancelled: future-1d' ) ;
383
381
} ) ;
384
382
385
383
it ( 'should render date component with its class and data attribute with "future-7d" value' , async ( ) => {
386
384
const future = DateParser . parseDate ( 'in 7 days' ) . format ( TaskRegularExpressions . dateFormat ) ;
387
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ future } ` , 'task-created' , 'taskCreated: future-7d' ) ;
388
385
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ future } ` , 'task-due' , 'taskDue: future-7d' ) ;
389
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ future } ` , 'task-scheduled' , 'taskScheduled: future-7d' ) ;
390
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ future } ` , 'task-start' , 'taskStart: future-7d' ) ;
391
- await testComponentClasses ( `- [x] Done task ✅ ${ future } ` , 'task-done' , 'taskDone: future-7d' ) ;
392
- await testComponentClasses ( `- [-] Canc task ❌ ${ future } ` , 'task-cancelled' , 'taskCancelled: future-7d' ) ;
393
386
} ) ;
394
387
395
388
it ( 'should render date component with its class and data attribute with "past-1d" value' , async ( ) => {
396
389
const past = DateParser . parseDate ( 'yesterday' ) . format ( TaskRegularExpressions . dateFormat ) ;
397
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ past } ` , 'task-created' , 'taskCreated: past-1d' ) ;
398
390
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ past } ` , 'task-due' , 'taskDue: past-1d' ) ;
399
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ past } ` , 'task-scheduled' , 'taskScheduled: past-1d' ) ;
400
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ past } ` , 'task-start' , 'taskStart: past-1d' ) ;
401
- await testComponentClasses ( `- [x] Done task ✅ ${ past } ` , 'task-done' , 'taskDone: past-1d' ) ;
402
- await testComponentClasses ( `- [-] Canc task ❌ ${ past } ` , 'task-cancelled' , 'taskCancelled: past-1d' ) ;
403
391
} ) ;
404
392
405
393
it ( 'should render date component with its class and data attribute with "past-7d" value' , async ( ) => {
406
394
const past = DateParser . parseDate ( '7 days ago' ) . format ( TaskRegularExpressions . dateFormat ) ;
407
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ past } ` , 'task-created' , 'taskCreated: past-7d' ) ;
408
395
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ past } ` , 'task-due' , 'taskDue: past-7d' ) ;
409
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ past } ` , 'task-scheduled' , 'taskScheduled: past-7d' ) ;
410
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ past } ` , 'task-start' , 'taskStart: past-7d' ) ;
411
- await testComponentClasses ( `- [x] Done task ✅ ${ past } ` , 'task-done' , 'taskDone: past-7d' ) ;
412
- await testComponentClasses ( `- [-] Canc task ❌ ${ past } ` , 'task-cancelled' , 'taskCancelled: past-7d' ) ;
413
396
} ) ;
414
397
415
398
it ( 'should render date component with its class and data attribute with "future-far"' , async ( ) => {
416
399
const future = DateParser . parseDate ( 'in 8 days' ) . format ( TaskRegularExpressions . dateFormat ) ;
417
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ future } ` , 'task-created' , 'taskCreated: future-far' ) ;
418
400
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ future } ` , 'task-due' , 'taskDue: future-far' ) ;
419
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ future } ` , 'task-scheduled' , 'taskScheduled: future-far' ) ;
420
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ future } ` , 'task-start' , 'taskStart: future-far' ) ;
421
- await testComponentClasses ( `- [x] Done task ✅ ${ future } ` , 'task-done' , 'taskDone: future-far' ) ;
422
- await testComponentClasses ( `- [-] Canc task ❌ ${ future } ` , 'task-cancelled' , 'taskCancelled: future-far' ) ;
423
401
} ) ;
424
402
425
403
it ( 'should render date component with its class and data attribute with "past-far" values' , async ( ) => {
426
404
const past = DateParser . parseDate ( '8 days ago' ) . format ( TaskRegularExpressions . dateFormat ) ;
427
- await testComponentClasses ( `- [ ] Full task ⏫ ➕ ${ past } ` , 'task-created' , 'taskCreated: past-far' ) ;
428
405
await testComponentClasses ( `- [ ] Full task ⏫ 📅 ${ past } ` , 'task-due' , 'taskDue: past-far' ) ;
429
- await testComponentClasses ( `- [ ] Full task ⏫ ⏳ ${ past } ` , 'task-scheduled' , 'taskScheduled: past-far' ) ;
430
- await testComponentClasses ( `- [ ] Full task ⏫ 🛫 ${ past } ` , 'task-start' , 'taskStart: past-far' ) ;
431
- await testComponentClasses ( `- [x] Done task ✅ ${ past } ` , 'task-done' , 'taskDone: past-far' ) ;
432
- await testComponentClasses ( `- [-] Canc task ❌ ${ past } ` , 'task-cancelled' , 'taskCancelled: past-far' ) ;
433
406
} ) ;
434
407
435
408
it ( 'should not add data attributes for invalid dates' , async ( ) => {
0 commit comments