@@ -53,4 +53,35 @@ describe('Headline', function()
53
53
assert .are .same (' headline_2_category' , file :get_headlines ()[2 ]:get_category ())
54
54
end )
55
55
end )
56
+
57
+ describe (' get_all_dates' , function ()
58
+ it (' should properly parse dates from the headline and body' , function ()
59
+ local file = helpers .create_file ({
60
+ ' * TODO testing <2024-08-17 Sat>' ,
61
+ ' DEADLINE: <2024-08-19 Mon>' ,
62
+ ' * stuff <2024-01-17 Wed>' ,
63
+ ' <2024-02-17 Sat>' ,
64
+ ' <2024-03-18 Sun>' ,
65
+ })
66
+
67
+ local assert_range = function (date , expected_range )
68
+ assert .are .same (expected_range [1 ], date .range .start_line , ' Start line is not matching' )
69
+ assert .are .same (expected_range [2 ], date .range .start_col , ' Start col is not matching' )
70
+ assert .are .same (expected_range [3 ], date .range .end_line , ' End line is not matching' )
71
+ assert .are .same (expected_range [4 ], date .range .end_col , ' End col is not matching' )
72
+ end
73
+
74
+ local first_headline_dates = file :get_headlines ()[1 ]:get_all_dates ()
75
+ assert .are .same (2 , # first_headline_dates )
76
+ assert_range (first_headline_dates [1 ], { 2 , 11 , 2 , 26 })
77
+ assert_range (first_headline_dates [2 ], { 1 , 16 , 1 , 31 })
78
+
79
+ local second_headline_dates = file :get_headlines ()[2 ]:get_all_dates ()
80
+ assert .are .same (3 , # second_headline_dates )
81
+ -- First date in the list is is always a plan date
82
+ assert_range (second_headline_dates [1 ], { 4 , 3 , 4 , 18 })
83
+ assert_range (second_headline_dates [2 ], { 3 , 9 , 3 , 24 })
84
+ assert_range (second_headline_dates [3 ], { 5 , 3 , 5 , 18 })
85
+ end )
86
+ end )
56
87
end )
0 commit comments