diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-06-12 08:13:15 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2017-06-12 08:13:15 -0400 |
| commit | c50de79c4828dbb4f9b5c23bf9e00ea4dea38a01 (patch) | |
| tree | 1c6a3a75ca21299e160778f9dd5fddb3be9f3828 /todolist/parser_test.go | |
| parent | cb849e5a8e0280d9fc10941d915f6252a0ad1cdc (diff) | |
Fix #64, parsing a todo with europe date format
* the `hasDue` function was not running, and therefore it was not parsing the due date.
* Also added the beginnings of a more holistic test approach, using `app_test.go`.
Diffstat (limited to 'todolist/parser_test.go')
| -rw-r--r-- | todolist/parser_test.go | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/todolist/parser_test.go b/todolist/parser_test.go index f5cc185..476edaa 100644 --- a/todolist/parser_test.go +++ b/todolist/parser_test.go @@ -75,27 +75,27 @@ func TestParseContexts(t *testing.T) { } func TestDueToday(t *testing.T) { + assert := assert.New(t) parser := &Parser{} + expectedDate := bod(time.Now()).Format("2006-01-02") + todo := parser.ParseNewTodo("do this thing with @bob and @mary due today") - if todo.Due != bod(time.Now()).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) + todo = parser.ParseNewTodo("do this thing with @bob and @mary due tod") - if todo.Due != bod(time.Now()).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) } func TestDueTomorrow(t *testing.T) { + assert := assert.New(t) parser := &Parser{} + expectedDate := bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") + todo := parser.ParseNewTodo("do this thing with @bob and @mary due tomorrow") - if todo.Due != bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) + todo = parser.ParseNewTodo("do this thing with @bob and @mary due tom") - if todo.Due != bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) } func TestDueSpecific(t *testing.T) { @@ -106,6 +106,14 @@ func TestDueSpecific(t *testing.T) { assert.Equal(fmt.Sprintf("%s-06-01", year), todo.Due) } +func TestDueSpecificEuropeanDate(t *testing.T) { + assert := assert.New(t) + parser := &Parser{} + todo := parser.ParseNewTodo("do this thing with @bob and @mary due 1 jun") + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-06-01", year), todo.Due) +} + func TestMondayOnSunday(t *testing.T) { assert := assert.New(t) parser := &Parser{} @@ -149,6 +157,14 @@ func TestDueOnSpecificDate(t *testing.T) { assert.Equal(fmt.Sprintf("%s-06-01", year), parser.Due("due jun 1", time.Now())) } +func TestDueOnSpecificDateEuropeFormat(t *testing.T) { + assert := assert.New(t) + parser := &Parser{} + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-05-02", year), parser.Due("due 2 may", time.Now())) + assert.Equal(fmt.Sprintf("%s-06-01", year), parser.Due("due 1 jun", time.Now())) +} + func TestDueOnSpecificDateEuropean(t *testing.T) { assert := assert.New(t) parser := &Parser{} |
