Преглед на файлове

Made tui code include address in height calculations

arianagiroux преди 1 седмица
родител
ревизия
77685c3fc5
променени са 2 файла, в които са добавени 6 реда и са изтрити 8 реда
  1. 3 5
      tui.go
  2. 3 3
      tui_test.go

+ 3 - 5
tui.go

@@ -180,12 +180,12 @@ func (m Model) View() tea.View {
 
 			if m.ChartHeight == 0 && len(m.Addresses) == 1 { // catch user specified fullscreen
 				// render chart at fullscreen
-				slc = streamlinechart.New(m.Width, m.Height)
+				slc = streamlinechart.New(m.Width, m.Height-1)
 			} else if m.ChartHeight == 0 && len(m.Addresses) > 1 { // catch user specified fullscreen
 				// render chart at fullscreen minus a few lines to hint at scrolling
-				slc = streamlinechart.New(m.Width, m.Height-5)
+				slc = streamlinechart.New(m.Width, m.Height-2)
 			} else {
-				slc = streamlinechart.New(m.Width, m.ChartHeight)
+				slc = streamlinechart.New(m.Width, m.ChartHeight-1)
 			}
 
 			for _, v := range address.Results {
@@ -197,8 +197,6 @@ func (m Model) View() tea.View {
 		}
 	}
 
-	content = content + "\n"
-
 	var v tea.View
 	v.SetContent(content)
 	v.AltScreen = true

+ 3 - 3
tui_test.go

@@ -59,7 +59,7 @@ func Test_Model_View(t *testing.T) {
 
 func Test_Model_View_init_state(t *testing.T) {
 	testModel := spawnTestModel(
-		[]string{"127.0.0.1", "cantresolvethisever"}, []float64{}, 0, 20, 10)
+		[]string{"127.0.0.1", "cantresolvethisever"}, []float64{}, 40, 20, 10)
 	result := testModel.View().Content
 	assert.IsType(t, *new(string), result)
 
@@ -114,7 +114,7 @@ func Test_Model_View_has_big_chart(t *testing.T) {
 	lines := strings.Split(result, "\n")
 	assert.True(t, strings.Contains(lines[1], "127.0.0.1"), lines[1])
 	assert.False(t, strings.Contains(lines[1], "loading..."))
-	assert.True(t, strings.Contains(lines[21], "0│"), result)
+	assert.True(t, strings.Contains(lines[20], "0│"), result)
 }
 
 func Test_Model_View_has_big_charts(t *testing.T) {
@@ -131,7 +131,7 @@ func Test_Model_View_has_big_charts(t *testing.T) {
 	for i, line := range lines {
 		if strings.Contains(line, "127.0.0.1") || strings.Contains(line, "cantresolvethisever") {
 			assert.False(t, strings.Contains(line, "loading..."))
-			assert.True(t, strings.Contains(lines[i+20], "0│"), lines[i+20]) // assert bottom of chart is where we expect it to be
+			assert.True(t, strings.Contains(lines[i+19], "0│"), lines[i+19]) // assert bottom of chart is where we expect it to be
 		}
 	}
 }