Skip to content

Commit

Permalink
Add simple test to check returning period as time
Browse files Browse the repository at this point in the history
  • Loading branch information
RadhiFadlillah committed Jul 5, 2024
1 parent 42bad63 commit fa4d0bb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,4 +1036,21 @@ func TestParser_Parse_customConfig(t *testing.T) {

dt, _ = parser.Parse(&cfg, "Понедельник")
assert.Equal(t, "ru", dt.Locale)

// Check returning period as time
cfg = dps.Configuration{
CurrentTime: tt(2024, 1, 1, 12, 0, 0),
ReturnTimeAsPeriod: true,
}

dt, _ = parser.Parse(&cfg, "in 10 minutes")
assert.Equal(t, tt(2024, 1, 1, 12, 10, 0), dt.Time)
assert.Equal(t, date.Minute, dt.Period)
assert.Equal(t, true, dt.Period.IsTime())

cfg.ReturnTimeAsPeriod = false
dt, _ = parser.Parse(&cfg, "in 10 minutes")
assert.Equal(t, tt(2024, 1, 1, 12, 10, 0), dt.Time)
assert.Equal(t, date.Day, dt.Period)
assert.Equal(t, false, dt.Period.IsTime())
}

0 comments on commit fa4d0bb

Please sign in to comment.