Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type MatrixCellID struct {
row int
}

// Row returns the row index associated with this ID
func (id MatrixCellID) Row() int {
return id.row
}

// MatrixRow an accessor to a line in a Matrix structure
// Line feed and return characters are trimmed from written strings to prevent breaking the layout of the matrix.
type MatrixRow interface {
Expand Down
1 change: 1 addition & 0 deletions matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestMatrixGetRowByID(t *testing.T) {

assert.NoError(t, err)
assert.Equal(t, aRow, fetchedRow)
assert.Equal(t, 1, fetchedRow.ID().Row())
}

func TestMatrixGetRowByIdWithInvalidRange(t *testing.T) {
Expand Down
17 changes: 17 additions & 0 deletions spinner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ func TestSpinnerCancellation(t *testing.T) {
assertStoppedEventually(t, probedWriter, spin.(*spinner))
}

func TestSpinnerBuilder(t *testing.T) {
expectedTitle := test.RandomString()
expectedInterval := time.Millisecond * 123
emulatedStdout := new(bytes.Buffer)

spin := NewSpinnerBuilder().
WithWriter(emulatedStdout).
WithTitle(expectedTitle).
WithInterval(expectedInterval).
Build()

s := spin.(*spinner)
assert.Equal(t, emulatedStdout, s.writer)
assert.Equal(t, expectedTitle, s.title)
assert.Equal(t, expectedInterval, s.interval)
}

func TestSpinnerTitles(t *testing.T) {
t.Run("InitialTitle", func(t *testing.T) {
expectedTitle := test.RandomString()
Expand Down
Loading