Skip to content

Commit

Permalink
Add calendar export test scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
alichtman committed Jul 3, 2023
1 parent 0a2f040 commit 1fa091d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jrnl/plugins/calendar_heatmap_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def print_calendar_heatmap(cls, journal_frequency: "NestedDict") -> str:
curr_year = datetime.now().year
curr_month = datetime.now().month
curr_day = datetime.now().day
hit_first_entry = False
with console.capture() as capture:
for year, month_journaling_freq in journal_frequency.items():
year_calendar = []
Expand All @@ -47,7 +48,12 @@ def print_calendar_heatmap(cls, journal_frequency: "NestedDict") -> str:
break

entries_this_month = sum(month_journaling_freq[month].values())
if entries_this_month == 0:
if not hit_first_entry and entries_this_month > 0:
hit_first_entry = True

if entries_this_month == 0 and not hit_first_entry:
continue
elif entries_this_month == 0:
entry_msg = "No entries"
elif entries_this_month == 1:
entry_msg = "1 entry"
Expand Down
13 changes: 13 additions & 0 deletions tests/bdd/features/format.feature
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,19 @@ Feature: Custom formats
| basic_dayone.yaml |


Scenario Outline: Export calendar heatmap
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --format calendar"
Then the output should be
2013-06-09, 1
2013-06-10, 1

Examples: configs
| config_file |
| simple.yaml |


Scenario Outline: display_format short and pretty do not crash if specified as config values
Given we use the config "<config_file>"
And we use the password "test" if prompted
Expand Down

0 comments on commit 1fa091d

Please sign in to comment.