Implement change order endpoint
This commit is contained in:
@@ -177,3 +177,33 @@ func TestAjaxMoveTask(t *testing.T) {
|
||||
t.Error(err, task)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAjaxChangeOrder(t *testing.T) {
|
||||
ajax := mockAjax()
|
||||
ajax.storageSetTask("list", &task.Task{UUID: "b", Title: "c", Index: 5})
|
||||
ajax.storageSetTask("list", &task.Task{UUID: "d", Title: "e", Index: 6})
|
||||
ajax.storageSetTask("list", &task.Task{UUID: "f", Title: "g", Index: 7})
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("POST", "/", strings.NewReader(`order=b%3d0%26d%3d-1%26f%3d-1%26`))
|
||||
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
ajax.changeOrder(w, r)
|
||||
if v := w.Code; v != http.StatusOK {
|
||||
t.Error(v)
|
||||
}
|
||||
tasks, err := ajax.storageListTasks("list")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(tasks) != 3 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if tasks[0].UUID != "d" {
|
||||
t.Error(tasks[0])
|
||||
}
|
||||
if tasks[1].UUID != "f" {
|
||||
t.Error(tasks[1])
|
||||
}
|
||||
if tasks[2].UUID != "b" {
|
||||
t.Error(tasks[2])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user