Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Merge c17232f into 977e97a
Browse files Browse the repository at this point in the history
  • Loading branch information
patorjk committed Oct 19, 2019
2 parents 977e97a + c17232f commit 9973b6a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mui-dt",
"version": "0.8.3",
"version": "0.9.0",
"description": "Datatables for React using Material-UI",
"main": "dist/index.js",
"files": [
Expand Down
60 changes: 58 additions & 2 deletions test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assembleCSV } from "../src/utils";
import { expect } from "chai";
import { assembleCSV, getPageValue } from "../src/utils";
import { expect, assert } from "chai";

describe("utils", () => {
describe("assembleCSV", () => {
Expand Down Expand Up @@ -63,4 +63,60 @@ import { expect } from "chai";
});
});
});

describe('getPageValue', () => {
it('returns the highest in bounds page value when page is out of bounds and count is greater than rowsPerPage', () => {
const count = 30;
const rowsPerPage = 10;
const page = 5;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 2);
});

it('returns the highest in bounds page value when page is in bounds and count is greater than rowsPerPage', () => {
const count = 30;
const rowsPerPage = 10;
const page = 1;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 1);
});

it('returns the highest in bounds page value when page is out of bounds and count is less than rowsPerPage', () => {
const count = 3;
const rowsPerPage = 10;
const page = 1;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 0);
});

it('returns the highest in bounds page value when page is in bounds and count is less than rowsPerPage', () => {
const count = 3;
const rowsPerPage = 10;
const page = 0;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 0);
});

it('returns the highest in bounds page value when page is out of bounds and count is equal to rowsPerPage', () => {
const count = 10;
const rowsPerPage = 10;
const page = 1;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 0);
});

it('returns the highest in bounds page value when page is in bounds and count is equal to rowsPerPage', () => {
const count = 10;
const rowsPerPage = 10;
const page = 0;

const actualResult = getPageValue(count, rowsPerPage, page);
assert.strictEqual(actualResult, 0);
});
});
});

0 comments on commit 9973b6a

Please sign in to comment.