Skip to content

Commit

Permalink
[Test] cover mode by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 17, 2024
1 parent e005d50 commit 978dea8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/paginator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func TestPaginator_GetPageCount(t *testing.T) {
assert.Equal(t, 5, *p.GetPageCount())
}

func TestPaginator_GetPageCount_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()

assert.Nil(t, p.GetPageCount(), "PageCount should be nil when itemCount is nil")
}

func TestPaginator_GetLastPage(t *testing.T) {
p := paginator.NewPaginator()

Expand All @@ -74,6 +80,12 @@ func TestPaginator_GetLastPage(t *testing.T) {
assert.Equal(t, 5, *p.GetLastPage())
}

func TestPaginator_GetLastPage_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()

assert.Nil(t, p.GetLastPage(), "LastPage should return nil when itemCount is nil")
}

func TestPaginator_IsFirst(t *testing.T) {
p := paginator.NewPaginator()

Expand Down Expand Up @@ -111,6 +123,12 @@ func TestPaginator_GetCountdownOffset(t *testing.T) {
assert.Equal(t, 20, *countdown)
}

func TestPaginator_GetCountdownOffset_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()

assert.Nil(t, p.GetCountdownOffset(), "CountdownOffset should be nil when itemCount is nil")
}

func TestPaginator_GetLength(t *testing.T) {
p := paginator.NewPaginator()

Expand All @@ -121,6 +139,13 @@ func TestPaginator_GetLength(t *testing.T) {
assert.Equal(t, 10, p.GetLength())
}

func TestPaginator_GetLength_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()
p.SetItemsPerPage(10)

assert.Equal(t, 10, p.GetLength(), "Length should return itemsPerPage when itemCount is nil")
}

func TestPaginator_GetFirstItemOnPage(t *testing.T) {
p := paginator.NewPaginator()

Expand All @@ -131,6 +156,13 @@ func TestPaginator_GetFirstItemOnPage(t *testing.T) {
assert.Equal(t, 1, p.GetFirstItemOnPage())
}

func TestPaginator_GetFirstItemOnPage_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()
p.SetPage(2)

assert.Equal(t, 0, p.GetFirstItemOnPage(), "FirstItemOnPage should return 0 when itemCount is nil")
}

func TestPaginator_GetLastItemOnPage(t *testing.T) {
p := paginator.NewPaginator()

Expand All @@ -141,6 +173,13 @@ func TestPaginator_GetLastItemOnPage(t *testing.T) {
assert.Equal(t, 10, p.GetLastItemOnPage())
}

func TestPaginator_GetLastItemOnPage_ItemCountNil(t *testing.T) {
p := paginator.NewPaginator()
p.SetPage(2)

assert.Equal(t, 0, p.GetLastItemOnPage(), "LastItemOnPage should return 0 when itemCount is nil")
}

func test1(t *testing.T) {
p := paginator.NewPaginator()
p.SetItemCount(7)
Expand Down

0 comments on commit 978dea8

Please sign in to comment.