diff --git a/src/app/cli/stop_test.go b/src/app/cli/stop_test.go index 2305064..124e0ad 100644 --- a/src/app/cli/stop_test.go +++ b/src/app/cli/stop_test.go @@ -34,13 +34,13 @@ func TestStopFallsBackToYesterday(t *testing.T) { `, state.writtenFileContents) } -func TestStopWithSummary(t *testing.T) { +func TestStopWithExtendingSummary(t *testing.T) { state, err := NewTestingContext()._SetRecords(` 1920-02-02 11:22-? Started something... `)._SetNow(1920, 2, 2, 15, 24)._Run((&Stop{ AtDateArgs: lib.AtDateArgs{Date: klog.Ɀ_Date_(1920, 2, 2)}, - Summary: " Done!", + Summary: "Done!", }).Run) require.Nil(t, err) assert.Equal(t, ` diff --git a/src/parser/reconciler_test.go b/src/parser/reconciler_test.go index 27327e8..684f2ed 100644 --- a/src/parser/reconciler_test.go +++ b/src/parser/reconciler_test.go @@ -80,7 +80,27 @@ func TestReconcilerRejectsInvalidEntry(t *testing.T) { assert.Error(t, err) } -func TestReconcilerClosesOpenRange(t *testing.T) { +func TestReconcilerClosesOpenRangeWithNewSummary(t *testing.T) { + original := ` +2018-01-01 + 15:00 - ? +` + pr, _ := Parse(original) + reconciler := NewRecordReconciler(pr, func(r Record) bool { + return r.Date().ToString() == "2018-01-01" + }) + require.NotNil(t, reconciler) + result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) { + return Ɀ_Time_(15, 22), "Finished." + }) + require.Nil(t, err) + assert.Equal(t, ` +2018-01-01 + 15:00 - 15:22 Finished. +`, result.NewText) +} + +func TestReconcilerClosesOpenRangeWithExtendingSummary(t *testing.T) { original := ` 2018-01-01 1h @@ -93,7 +113,7 @@ func TestReconcilerClosesOpenRange(t *testing.T) { }) require.NotNil(t, reconciler) result, err := reconciler.CloseOpenRange(func(r Record) (Time, Summary) { - return Ɀ_Time_(16, 42), " Yes!" + return Ɀ_Time_(16, 42), "Yes!" }) require.Nil(t, err) assert.Equal(t, `