diff options
Diffstat (limited to 'parser_test.go')
| -rw-r--r-- | parser_test.go | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/parser_test.go b/parser_test.go index 9e1c9cf..980aad2 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1,6 +1,12 @@ package todolist -import "testing" +import ( + "fmt" + "testing" + "time" + + "github.com/jinzhu/now" +) func TestParseSubject(t *testing.T) { parser := &Parser{} @@ -31,3 +37,47 @@ func TestParseProjects(t *testing.T) { t.Error("todo.Projects[1] should equal 'proj2' but got", todo.Projects[1]) } } + +func TestParseContexts(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing with @bob and @mary due tomorrow") + if len(todo.Contexts) != 2 { + t.Error("Expected Projects length to be 2") + } + if todo.Contexts[0] != "bob" { + t.Error("todo.Contexts[0] should equal 'mary' but got", todo.Contexts[0]) + } + if todo.Contexts[1] != "mary" { + t.Error("todo.Contexts[1] should equal 'mary' but got", todo.Contexts[1]) + } +} + +func TestDueToday(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing with @bob and @mary due today") + if todo.Due != now.BeginningOfDay() { + fmt.Println("Date is different", todo.Due, time.Now()) + } +} + +func TestDueTomorrow(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing with @bob and @mary due tomorrow") + if todo.Due != now.BeginningOfDay().AddDate(0, 0, 1) { + fmt.Println("Date is different", todo.Due, time.Now()) + } +} + +//func TestDueNextWeek(t *testing.T) { +// parser := &Parser{} +// +// fmt.Println("about to parse") +// todo := parser.Parse("do this thing with @bob and @mary due next week") +// fmt.Println(todo.Due) +//} + +func TestDueMonday(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing with @bob and @mary due mon") + fmt.Println(todo.Due) +} |
