fixed paging with NaN page numbers

This commit is contained in:
Sebastian Sdorra
2018-10-17 11:55:47 +02:00
parent 229a46c344
commit efb857150b
4 changed files with 58 additions and 20 deletions

View File

@@ -0,0 +1,26 @@
import { getPageFromMatch } from "./Changesets";
describe("tests for getPageFromMatch", () => {
function createMatch(page: string) {
return {
params: {
page
}
};
}
it("should return 1 for NaN", () => {
const match = createMatch("any");
expect(getPageFromMatch(match)).toBe(1);
});
it("should return 1 for 0", () => {
const match = createMatch("0");
expect(getPageFromMatch(match)).toBe(1);
});
it("should return the given number", () => {
const match = createMatch("42");
expect(getPageFromMatch(match)).toBe(42);
});
});