From c3558c0b0c0bd32c3f2c098a6a3c99d1f34c08aa Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 4 Dec 2025 12:47:18 +0000 Subject: [PATCH] test: ensure scolling logic and initialisation logic are working --- .../components/chat/editor/history_test.go | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 internal/tui/components/chat/editor/history_test.go diff --git a/internal/tui/components/chat/editor/history_test.go b/internal/tui/components/chat/editor/history_test.go new file mode 100644 index 0000000000000000000000000000000000000000..ae97a85c8a9687af9f624c74337ffcb2edcef343 --- /dev/null +++ b/internal/tui/components/chat/editor/history_test.go @@ -0,0 +1,39 @@ +package editor + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestIntialiseHistoryWithExistingValue(t *testing.T) { + fakeHistory := []string{ + "1. This is the first message", + "2. This is the second message", + "3. This is the third message", + } + + h := InitialiseHistory("This is existing content in the input field", fakeHistory) + + assert.Equal(t, h.ExistingValue(), "This is existing content in the input field") + assert.Equal(t, h.Value(), "This is existing content in the input field") +} + +func TestIntialiseHistoryScrollUp(t *testing.T) { + fakeHistory := []string{ + "1. This is the first message", + "2. This is the second message", + "3. This is the third message", + } + + h := InitialiseHistory("This is existing content in the input field", fakeHistory) + assert.Equal(t, h.ExistingValue(), "This is existing content in the input field") + assert.Equal(t, h.Value(), "This is existing content in the input field") + + h.ScrollUp() + assert.Equal(t, h.Value(), "3. This is the third message") + h.ScrollUp() + assert.Equal(t, h.Value(), "2. This is the second message") + h.ScrollUp() + assert.Equal(t, h.Value(), "1. This is the first message") +}