@Test
fun `new pagination is at page number 1`() {
- assertThat(pagination.pageNumber, equalTo(1))
+ assertThat(pagination.pageNumber, equalTo(1))
}
@Test
@Test
fun `the page count is returned correctly`() {
- assertThat(pagination.pageCount, equalTo(3))
+ assertThat(pagination.pageCount, equalTo(3))
}
@Test
fun `page size is returned correctly`() {
- assertThat(pagination.pageSize, equalTo(2))
+ assertThat(pagination.pageSize, equalTo(2))
}
@Test
fun `a page size of less than 1 is set to 1`() {
- pagination.pageSize = 0
+ pagination.pageSize = 0
assertThat(pagination.pageSize, equalTo(1))
}
@Test
fun `changing page size sets new page correctly`() {
pagination.page = 1
- pagination.pageSize = 1
+ pagination.pageSize = 1
assertThat(pagination.page, equalTo(2))
}
@Test
fun `changing page size to very large returns to page 0`() {
- pagination.page = 1
+ pagination.page = 1
pagination.pageSize = 20
assertThat(pagination.page, equalTo(0))
}
@Test
fun `item count for current page is page size of first page`() {
- assertThat(pagination.itemCount, equalTo(2))
+ assertThat(pagination.itemCount, equalTo(2))
}
@Test
fun `item count for last page is 1`() {
- pagination.page = 2
+ pagination.page = 2
assertThat(pagination.itemCount, equalTo(1))
}
@Test
fun `items on first page are returned correctly`() {
- assertThat(pagination.items, contains(1, 2))
+ assertThat(pagination.items, contains(1, 2))
}
@Test
fun `items on last page are returned correctly`() {
- pagination.page = 2
+ pagination.page = 2
assertThat(pagination.items, contains(5))
}
@Test
fun `pagination is first on first page`() {
- assertThat(pagination.isFirst, equalTo(true))
+ assertThat(pagination.isFirst, equalTo(true))
}
@Test
fun `pagination is not first on second page`() {
pagination.page = 1
- assertThat(pagination.isFirst, equalTo(false))
+ assertThat(pagination.isFirst, equalTo(false))
}
@Test
fun `pagination is not first on last page`() {
pagination.page = 2
- assertThat(pagination.isFirst, equalTo(false))
+ assertThat(pagination.isFirst, equalTo(false))
}
@Test
fun `pagination is not last on first page`() {
- assertThat(pagination.isLast, equalTo(false))
+ assertThat(pagination.isLast, equalTo(false))
}
@Test
fun `pagination is not last on second page`() {
pagination.page = 1
- assertThat(pagination.isLast, equalTo(false))
+ assertThat(pagination.isLast, equalTo(false))
}
@Test
fun `pagination is last on last page`() {
pagination.page = 2
- assertThat(pagination.isLast, equalTo(true))
+ assertThat(pagination.isLast, equalTo(true))
}
@Test
fun `pagination is necessary for three pages`() {
- assertThat(pagination.isNecessary, equalTo(true))
+ assertThat(pagination.isNecessary, equalTo(true))
}
@Test
fun `pagination is necessary for two pages`() {
- pagination.pageSize = 4
+ pagination.pageSize = 4
assertThat(pagination.isNecessary, equalTo(true))
}
@Test
fun `previous page is returned correctly for second page`() {
pagination.page = 1
- assertThat(pagination.previousPage, equalTo(0))
+ assertThat(pagination.previousPage, equalTo(0))
}
@Test
@Test
fun `next page is returned correctly for first page`() {
- assertThat(pagination.nextPage, equalTo(1))
+ assertThat(pagination.nextPage, equalTo(1))
}
@Test
fun `next page is returned correctly for second page`() {
pagination.page = 1
- assertThat(pagination.nextPage, equalTo(2))
+ assertThat(pagination.nextPage, equalTo(2))
}
@Test
fun `last page is returned correctly`() {
- assertThat(pagination.lastPage, equalTo(2))
+ assertThat(pagination.lastPage, equalTo(2))
}
@Test
fun `iterator returns items on the current page`() {
- assertThat(pagination.iterator().asSequence().toList(), contains(1, 2))
+ assertThat(pagination.iterator().asSequence().toList(), contains(1, 2))
}
}