Refresh task view dynamically with Javascript
All checks were successful
Alpine 3.20 Success

This is more efficient, responsive, and user friendly.
This commit is contained in:
2024-12-26 18:41:29 +01:00
parent 4f2c2dc8da
commit d83517f67b
3 changed files with 220 additions and 55 deletions

View File

@@ -1,6 +1,9 @@
package main
import "testing"
import (
"slices"
"testing"
)
// This could be way more extensive, but we're not aiming for perfection.
var tests = []struct {
@@ -68,3 +71,30 @@ Loop:
}
}
}
func TestTerminalUpdateGroups(t *testing.T) {
tw := terminalWriter{}
collect := func() (have []int) {
for _, line := range tw.lines {
have = append(have, line.updateGroup)
}
return
}
// 0: A 0 0 0
// 1: B X 1 1 1
// 2: C Y 1 2 1 1
// 3: Z 2 3 2
// 4: 3 4
tw.Write([]byte("A\nB\nC\x1b[FX\nY\nZ"))
have, want := collect(), []int{0, 1, 1, 3}
if !slices.Equal(want, have) {
t.Errorf("update groups: %+v; want: %+v", have, want)
}
tw.Write([]byte("\x1b[F1\n2\n3"))
have, want = collect(), []int{0, 1, 1, 2, 4}
if !slices.Equal(want, have) {
t.Errorf("update groups: %+v; want: %+v", have, want)
}
}