aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--todolist/app_test.go12
-rw-r--r--todolist/parser.go2
2 files changed, 13 insertions, 1 deletions
diff --git a/todolist/app_test.go b/todolist/app_test.go
index 2fb7717..360da43 100644
--- a/todolist/app_test.go
+++ b/todolist/app_test.go
@@ -44,6 +44,18 @@ func TestAddTodoWithEuropeanDates(t *testing.T) {
assert.Equal([]string{}, todo.Contexts)
}
+func TestAddEmptyTodo(t *testing.T) {
+ assert := assert.New(t)
+ app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}}
+
+ app.AddTodo("a")
+ app.AddTodo("a ")
+ app.AddTodo("a\t\t\t\t")
+ app.AddTodo("a\t \t \t \t")
+
+ assert.Equal(len(app.TodoList.Data), 0)
+}
+
func TestListbyProject(t *testing.T) {
assert := assert.New(t)
app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}}
diff --git a/todolist/parser.go b/todolist/parser.go
index cdfb179..d62c77d 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -12,7 +12,7 @@ import (
type Parser struct{}
func (p *Parser) ParseNewTodo(input string) *Todo {
- r, _ := regexp.Compile(`^(add|a)(\\ |) `)
+ r, _ := regexp.Compile(`^(add|a)(\s*|)`)
input = r.ReplaceAllString(input, "")
if input == "" {
return nil