forked from Mirrors/bubbletea
chore: update example tests, test on ci (#735)
* chore: update example tests, test on ci Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: mark *.golden as binary Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
f3e1b67605
commit
b2d2ac6504
|
@ -0,0 +1 @@
|
|||
*.golden -text
|
|
@ -32,6 +32,10 @@ jobs:
|
|||
run: go build -v ./...
|
||||
working-directory: ./examples
|
||||
|
||||
- name: Test examples
|
||||
run: go test -v ./...
|
||||
working-directory: ./examples
|
||||
|
||||
- name: Build tutorials
|
||||
run: go build -v ./...
|
||||
working-directory: ./tutorials
|
||||
|
|
|
@ -8,9 +8,15 @@ import (
|
|||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/x/exp/teatest"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
lipgloss.SetColorProfile(termenv.Ascii)
|
||||
}
|
||||
|
||||
func TestApp(t *testing.T) {
|
||||
m := model(10)
|
||||
tm := teatest.NewTestModel(
|
||||
|
@ -34,13 +40,13 @@ func TestApp(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
out := readBts(t, tm.FinalOutput())
|
||||
out := readBts(t, tm.FinalOutput(t))
|
||||
if !regexp.MustCompile(`This program will exit in \d+ seconds`).Match(out) {
|
||||
t.Fatalf("output does not match the given regular expression: %s", string(out))
|
||||
}
|
||||
teatest.RequireEqualOutput(t, out)
|
||||
|
||||
if tm.FinalModel().(model) != 9 {
|
||||
if tm.FinalModel(t).(model) != 9 {
|
||||
t.Errorf("expected model to be 10, was %d", m)
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +77,7 @@ func TestAppInteractive(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if tm.FinalModel().(model) != 7 {
|
||||
if tm.FinalModel(t).(model) != 7 {
|
||||
t.Errorf("expected model to be 7, was %d", m)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[?25lHi. This program will exit in 10 seconds. To quit sooner press any key
|
||||
[70D[1A[70D[2KHi. This program will exit in 9 seconds. To quit sooner press any key.
|
||||
[?25lHi. This program will exit in 10 seconds. To quit sooner press any key
|
||||
[70D[1A[70D[2KHi. This program will exit in 9 seconds. To quit sooner press any key.
|
||||
[70D[2K[?25h[?1002l[?1003l
|
Loading…
Reference in New Issue