func TestFocusedMovesWhenMoveKeysPressedPaged(t *testing.T) {
	cols := []Column{
		NewColumn("id", "ID", 3),
	}

	model := New(cols).WithRows([]Row{
		NewRow(RowData{
			"id": "first",
		}),
		NewRow(RowData{
			"id": "second",
		}),
		NewRow(RowData{
			"id": "third",
		}),
	}).Focused(true).WithPageSize(2)

	// Note that this is assuming default keymap
	keyUp := tea.KeyMsg{Type: tea.KeyUp}
	keyDown := tea.KeyMsg{Type: tea.KeyDown}
	keyLeft := tea.KeyMsg{Type: tea.KeyLeft}
	keyRight := tea.KeyMsg{Type: tea.KeyRight}
	keyHome := tea.KeyMsg{Type: tea.KeyHome}
	keyEnd := tea.KeyMsg{Type: tea.KeyEnd}

	curID := func() string {
		str, ok := model.HighlightedRow().Data["id"].(string)

		assert.True(t, ok, "Failed to convert to string")

		return str
	}

	assert.Equal(t, "first", curID(), "Should start on first row")

	model, _ = model.Update(keyDown)
	assert.Equal(t, "second", curID(), "Default key down should move down a row")

	model, _ = model.Update(keyUp)
	assert.Equal(t, "first", curID(), "Should move back up")

	model, _ = model.Update(keyUp)
	assert.Equal(t, "third", curID(), "Moving up from top should wrap to bottom")

	model, _ = model.Update(keyDown)
	assert.Equal(t, "first", curID(), "Moving down from bottom should wrap to top")

	model, _ = model.Update(keyRight)
	assert.Equal(t, "third", curID(), "Moving right should move to second page")

	model, _ = model.Update(keyRight)
	assert.Equal(t, "first", curID(), "Moving right again should move to first page")

	model, _ = model.Update(keyLeft)
	assert.Equal(t, "third", curID(), "Moving left should move to last page")

	model, _ = model.Update(keyLeft)
	assert.Equal(t, "first", curID(), "Moving left should move back to first page")

	model, _ = model.Update(keyDown)
	assert.Equal(t, "second", curID(), "Should be back down to second row")

	model, _ = model.Update(keyHome)
	assert.Equal(t, "first", curID(), "Hitting home should go to first page and select first row")

	model, _ = model.Update(keyHome)
	assert.Equal(t, "first", curID(), "Hitting home a second time should not move pages")

	model, _ = model.Update(keyEnd)
	assert.Equal(t, "third", curID(), "Hitting end should move to last page")

	model, _ = model.Update(keyEnd)
	assert.Equal(t, "third", curID(), "Hitting end a second time should not move pages")
}
// This is a long test with a lot of movement keys pressed, that's okay because
// it's simply repetitive and tracking the same kind of state change many times
// nolint: funlen
This is a long test with a lot of movement keys pressed, that's okay because
it's simply repetitive and tracking the same kind of state change many times
nolint: funlen
// This is a long test with a lot of movement keys pressed that ' s okay because // it ' s simply repetitive and tracking the same kind of state change many times // nolint : funlen
func TestFocusedMovesWhenMoveKeysPressedPaged(t *testing.T) {
	cols := []Column{
		NewColumn("id", "ID", 3),
	}
	model := New(cols).WithRows([]Row{
		NewRow(RowData{
			"id": "first",
		}),
		NewRow(RowData{
			"id": "second",
		}),
		NewRow(RowData{
			"id": "third",
		}),
	}).Focused(true).WithPageSize(2)
	keyUp := tea.KeyMsg{Type: tea.KeyUp}
	keyDown := tea.KeyMsg{Type: tea.KeyDown}
	keyLeft := tea.KeyMsg{Type: tea.KeyLeft}
	keyRight := tea.KeyMsg{Type: tea.KeyRight}
	keyHome := tea.KeyMsg{Type: tea.KeyHome}
	keyEnd := tea.KeyMsg{Type: tea.KeyEnd}
	curID := func() string {
		str, ok := model.HighlightedRow().Data["id"].(string)
		assert.True(t, ok, "Failed to convert to string")
		return str
	}
	assert.Equal(t, "first", curID(), "Should start on first row")
	model, _ = model.Update(keyDown)
	assert.Equal(t, "second", curID(), "Default key down should move down a row")
	model, _ = model.Update(keyUp)
	assert.Equal(t, "first", curID(), "Should move back up")
	model, _ = model.Update(keyUp)
	assert.Equal(t, "third", curID(), "Moving up from top should wrap to bottom")
	model, _ = model.Update(keyDown)
	assert.Equal(t, "first", curID(), "Moving down from bottom should wrap to top")
	model, _ = model.Update(keyRight)
	assert.Equal(t, "third", curID(), "Moving right should move to second page")
	model, _ = model.Update(keyRight)
	assert.Equal(t, "first", curID(), "Moving right again should move to first page")
	model, _ = model.Update(keyLeft)
	assert.Equal(t, "third", curID(), "Moving left should move to last page")
	model, _ = model.Update(keyLeft)
	assert.Equal(t, "first", curID(), "Moving left should move back to first page")
	model, _ = model.Update(keyDown)
	assert.Equal(t, "second", curID(), "Should be back down to second row")
	model, _ = model.Update(keyHome)
	assert.Equal(t, "first", curID(), "Hitting home should go to first page and select first row")
	model, _ = model.Update(keyHome)
	assert.Equal(t, "first", curID(), "Hitting home a second time should not move pages")
	model, _ = model.Update(keyEnd)
	assert.Equal(t, "third", curID(), "Hitting end should move to last page")
	model, _ = model.Update(keyEnd)
	assert.Equal(t, "third", curID(), "Hitting end a second time should not move pages")
}
func TestFocusedMovesWhenMoveKeysPressedPaged ( t * testing . T ) { cols := [ ] Column { NewColumn ( " " , " " , 3 ) , } model := New ( cols ) . WithRows ( [ ] Row { NewRow ( RowData { " " : " " , } ) , NewRow ( RowData { " " : " " , } ) , NewRow ( RowData { " " : " " , } ) , } ) . Focused ( true ) . WithPageSize ( 2 ) keyUp := tea . KeyMsg { Type : tea . KeyUp } keyDown := tea . KeyMsg { Type : tea . KeyDown } keyLeft := tea . KeyMsg { Type : tea . KeyLeft } keyRight := tea . KeyMsg { Type : tea . KeyRight } keyHome := tea . KeyMsg { Type : tea . KeyHome } keyEnd := tea . KeyMsg { Type : tea . KeyEnd } curID := func ( ) string { str , ok := model . HighlightedRow ( ) . Data [ " " ] . ( string ) assert . True ( t , ok , " " ) return str } assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyDown ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyUp ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyUp ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyDown ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyRight ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyRight ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyLeft ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyLeft ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyDown ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyHome ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyHome ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyEnd ) assert . Equal ( t , " " , curID ( ) , " " ) model , _ = model . Update ( keyEnd ) assert . Equal ( t , " " , curID ( ) , " " ) }
This is a long test with a lot of movement keys pressed, that's okay because
it's simply repetitive and tracking the same kind of state change many times
nolint: funlen
This is a long test with a lot of movement keys pressed that ' s okay because it ' s simply repetitive and tracking the same kind of state change many times nolint : funlen
// Note that this is assuming default keymap