github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/components/pagination/pagination.spec.ts (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import { assert } from "chai"; 12 import { 13 paginationPageCount, 14 } from "./pagination"; 15 16 const match = { 17 path: "/test/:app", 18 url: "/test/$ cockroach demo", 19 isExact: true, 20 params: { 21 app: "$ cockroach demo", 22 }, 23 }; 24 25 describe("Pagination", () => { 26 describe("page count", () => { 27 it("get page count label", () => { 28 assert.equal(paginationPageCount({ pageSize: 20, current: 1, total: 200 }, "test"), "1-20 of 200 test"); 29 assert.equal(paginationPageCount({ pageSize: 20, current: 1, total: 7 }, "test"), "1-7 of 7 test"); 30 assert.equal(paginationPageCount({ pageSize: 20, current: 1, total: 0 }, "test"), "0 test"); 31 assert.equal(paginationPageCount({ pageSize: 10, current: 2, total: 15 }, "test"), "11-15 of 15 test"); 32 assert.equal(paginationPageCount({ pageSize: 20, current: 2, total: 300 }, "test", match, "app"), "21-40 of 300 results"); 33 assert.equal(paginationPageCount({ pageSize: 20, current: 1, total: 64 }, "test", match, "app", "test"), "1-20 of 64 results"); 34 assert.equal(paginationPageCount({ pageSize: 20, current: 1, total: 0 }, "test", match, "app", "search"), "0 results"); 35 assert.equal(paginationPageCount({ pageSize: 10, current: 2, total: 15 }, "test", match, "app", "search"), "11-15 of 15 results"); 36 }); 37 }); 38 });