2018-08-23 09:10:38 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { mount, shallow } from "enzyme";
|
|
|
|
|
import "../../tests/enzyme";
|
|
|
|
|
import "../../tests/i18n";
|
2018-09-13 08:28:50 +02:00
|
|
|
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
2018-08-23 09:10:38 +02:00
|
|
|
import PermissionsNavLink from "./PermissionsNavLink";
|
2018-09-11 16:17:11 +02:00
|
|
|
|
|
|
|
|
describe("PermissionsNavLink", () => {
|
2018-09-13 08:28:50 +02:00
|
|
|
const options = new ReactRouterEnzymeContext();
|
|
|
|
|
|
2018-08-23 09:10:38 +02:00
|
|
|
it("should render nothing, if the modify link is missing", () => {
|
|
|
|
|
const repository = {
|
|
|
|
|
_links: {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const navLink = shallow(
|
2018-09-13 08:28:50 +02:00
|
|
|
<PermissionsNavLink repository={repository} permissionUrl="" />,
|
|
|
|
|
options.get()
|
2018-08-23 09:10:38 +02:00
|
|
|
);
|
|
|
|
|
expect(navLink.text()).toBe("");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should render the navLink", () => {
|
|
|
|
|
const repository = {
|
|
|
|
|
_links: {
|
|
|
|
|
permissions: {
|
|
|
|
|
href: "/permissions"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const navLink = mount(
|
2018-09-13 08:28:50 +02:00
|
|
|
<PermissionsNavLink repository={repository} permissionUrl="" />,
|
|
|
|
|
options.get()
|
2018-08-23 09:10:38 +02:00
|
|
|
);
|
2019-01-02 15:03:45 +01:00
|
|
|
expect(navLink.text()).toBe(" repository-root.permissions");
|
2018-08-23 09:10:38 +02:00
|
|
|
});
|
|
|
|
|
});
|