2018-10-17 14:11:28 +02:00
|
|
|
// @flow
|
2018-10-17 17:11:21 +02:00
|
|
|
import { getPageFromMatch } from "./urls";
|
2018-10-17 11:55:47 +02:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|