more realistic pathnames in tests

pull/462/head
gabrielburnworth 2017-09-21 22:44:21 -07:00
parent 33c48c5851
commit 9b2df063c1
5 changed files with 13 additions and 7 deletions

View File

@ -1,7 +1,7 @@
jest.mock("../../../history", () => ({
history: {
getCurrentLocation: () => {
return { pathname: "//////add" };
return { pathname: "/app/designer/plants/crop_search/aplant/add" };
}
}
}));

View File

@ -3,9 +3,15 @@ jest.mock("../../../history", () => ({
history: {
push: mockHistory,
getCurrentLocation: jest.fn()
.mockImplementationOnce(() => { return { pathname: "//app/plants" } })
.mockImplementationOnce(() => { return { pathname: "//app/plants/1/edit" } })
.mockImplementationOnce(() => { return { pathname: "//app/plants/1" } })
.mockImplementationOnce(() => {
return { pathname: "/app/designer/plants" }
})
.mockImplementationOnce(() => {
return { pathname: "/app/designer/plants/1/edit" }
})
.mockImplementationOnce(() => {
return { pathname: "/app/designer/plants/1" }
})
}
}));

View File

@ -25,7 +25,7 @@ describe("<AddPlant />", () => {
}]
};
Object.defineProperty(location, "pathname", {
value: "//app/plants/crop_search/mint/add"
value: "/app/designer/plants/crop_search/mint/add"
});
const wrapper = mount(<AddPlant {...props} />);
expect(wrapper.text()).toContain("Mint");

View File

@ -27,7 +27,7 @@ import { shallow } from "enzyme";
describe("<CropInfo />", () => {
it("renders", () => {
Object.defineProperty(location, "pathname", {
value: "//app/plants/crop_search/mint"
value: "/app/designer/plants/crop_search/mint"
});
const wrapper = shallow(
<CropInfo

View File

@ -11,7 +11,7 @@ describe("<SelectPlants />", () => {
beforeEach(function () {
jest.clearAllMocks();
Object.defineProperty(location, "pathname", {
value: "//app/plants/select"
value: "/app/designer/plants/select"
});
});