2019-10-20 18:02:52 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { shallow, mount } from "@scm-manager/ui-tests/enzyme-router";
|
|
|
|
|
import "@scm-manager/ui-tests/i18n";
|
|
|
|
|
import RepositoryNavLink from "./RepositoryNavLink";
|
2019-10-19 16:38:07 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
describe("RepositoryNavLink", () => {
|
|
|
|
|
it("should render nothing, if the sources link is missing", () => {
|
2019-10-19 16:38:07 +02:00
|
|
|
const repository = {
|
2019-10-20 18:02:52 +02:00
|
|
|
namespace: "Namespace",
|
|
|
|
|
name: "Repo",
|
|
|
|
|
type: "GIT",
|
|
|
|
|
_links: {}
|
2019-10-19 16:38:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const navLink = shallow(
|
|
|
|
|
<RepositoryNavLink
|
|
|
|
|
repository={repository}
|
|
|
|
|
linkName="sources"
|
|
|
|
|
to="/sources"
|
|
|
|
|
label="Sources"
|
|
|
|
|
activeOnlyWhenExact={true}
|
2019-10-20 18:02:52 +02:00
|
|
|
/>
|
2019-10-19 16:38:07 +02:00
|
|
|
);
|
2019-10-20 18:02:52 +02:00
|
|
|
expect(navLink.text()).toBe("");
|
2019-10-19 16:38:07 +02:00
|
|
|
});
|
|
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
it("should render the navLink", () => {
|
2019-10-19 16:38:07 +02:00
|
|
|
const repository = {
|
2019-10-20 18:02:52 +02:00
|
|
|
namespace: "Namespace",
|
|
|
|
|
name: "Repo",
|
|
|
|
|
type: "GIT",
|
2019-10-19 16:38:07 +02:00
|
|
|
_links: {
|
|
|
|
|
sources: {
|
2019-10-20 18:02:52 +02:00
|
|
|
href: "/sources"
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-19 16:38:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const navLink = mount(
|
|
|
|
|
<RepositoryNavLink
|
|
|
|
|
repository={repository}
|
|
|
|
|
linkName="sources"
|
|
|
|
|
to="/sources"
|
|
|
|
|
label="Sources"
|
|
|
|
|
activeOnlyWhenExact={true}
|
2019-10-20 18:02:52 +02:00
|
|
|
/>
|
2019-10-19 16:38:07 +02:00
|
|
|
);
|
2019-10-20 18:02:52 +02:00
|
|
|
expect(navLink.text()).toBe("Sources");
|
2019-10-19 16:38:07 +02:00
|
|
|
});
|
|
|
|
|
});
|