import { AppRoute } from "../../routes.defs";
import { default as buildRouteLink } from "./buildRouteLink";
describe("buildRouteLink", () => {
it(`should return path from route without transform when it gets called with a null as routeParams argument`, () => {
const routeName: AppRoute = AppRoute.HOME;
const link = buildRouteLink(routeName, null);
expect(link).toMatchInlineSnapshot(`"/"`);
});
it(`should return path from route without transform when it gets called with an empty object as routeParams argument`, () => {
const routeName: AppRoute = AppRoute.HOME;
const link = buildRouteLink(routeName, {});
expect(link).toMatchInlineSnapshot(`"/"`);
});
it(`should return path from route with params values when it gets called with an object containing values as routeParams argument`, () => {
const routeName: AppRoute = AppRoute.ORGANIZATION_DETAILS;
const link = buildRouteLink(routeName, {
orgSlug: "my-super-org",
});
expect(link).toMatchInlineSnapshot(`"/my-super-org"`);
});
it(`should return path from route with params values when it gets called with an object containing values and magic "*" value as routeParams argument`, () => {
const routeName: AppRoute = AppRoute.REPOSITORY_BROWSER_WITH_PATH;
const link = buildRouteLink(routeName, {
orgSlug: "my-super-org",
repoSlug: "my-super-repo",
currentRef: "main",
"*": "app.manifest.json",
});
expect(link).toMatchInlineSnapshot(
`"/my-super-org/my-super-repo/main/tree/app.manifest.json"`
);
});
it(`should return path from route with url encoded params values when it gets called with an object containing values as routeParams argument`, () => {
const routeName: AppRoute = AppRoute.REPOSITORY_BROWSER_WITH_PATH;
const link = buildRouteLink(routeName, {
orgSlug: "my-super-org",
repoSlug: "my-super-repo",
currentRef: "main",
"*": "app/services/auth/isExistingEmailAddress.ts",
});
expect(link).toMatchInlineSnapshot(
`"/my-super-org/my-super-repo/main/tree/app%2Fservices%2Fauth%2FisExistingEmailAddress.ts"`
);
});
});
describe("buildPathLink", () => {});