(t *testing.T)
| 302 | } |
| 303 | |
| 304 | func TestTableModel_SortPreservedAfterSetRows(t *testing.T) { |
| 305 | cols := []Column{{Title: "Name"}, {Title: "Value"}} |
| 306 | table := NewTableModel(cols) |
| 307 | table.SetSize(80, 25) |
| 308 | |
| 309 | // Set sort field to column 1 (Value) |
| 310 | table.NextSort() // now sorting by column 1 |
| 311 | |
| 312 | rows := []TableRow{ |
| 313 | testRow{id: "1", cols: []string{"cherry", "c"}}, |
| 314 | testRow{id: "2", cols: []string{"apple", "a"}}, |
| 315 | testRow{id: "3", cols: []string{"banana", "b"}}, |
| 316 | } |
| 317 | table.SetRows(rows) |
| 318 | // SetRows does NOT re-sort, so order is insertion order |
| 319 | r := table.SelectedRow() |
| 320 | if r == nil || r.ID() != "1" { |
| 321 | t.Fatalf("expected first row id '1' after SetRows (no sort), got %v", r) |
| 322 | } |
| 323 | |
| 324 | // Calling Sort() should re-sort by column 1 (Value) |
| 325 | table.Sort() |
| 326 | r = table.SelectedRow() |
| 327 | if r == nil || r.Columns()[1] != "a" { |
| 328 | t.Fatalf("expected first row value 'a' after Sort(), got %v", r) |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | func TestTableModel_ViewNotEmpty(t *testing.T) { |
| 333 | cols := []Column{{Title: "Name", Width: 20, Fixed: true}} |
nothing calls this directly
no test coverage detected