react-canada-map
Version:
react module for an interactive map of Canada
47 lines • 4.96 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import * as React from "react";
import { configure, shallow } from "enzyme";
import * as Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import Province from "../Province";
configure({ adapter: new Adapter() });
describe("Component: Province", function () {
var element;
var onClickProvinceMock;
beforeEach(function () {
onClickProvinceMock = jest.fn();
var componentProps = {
onClick: onClickProvinceMock,
provinceName: "Prince Edward Island",
provinceAbbreviation: "PEI",
dimensions: "m24511 8379-12 36-35 80-16 29-14 9-8 14 3 6-5 11-13 2-3 11-19 14-55-15 16 9 7 12 10 4-1 14-8 5-26-7-33 17 25-1 4 33 19 1-26 17-24 5 28 5 20 10-9 9 5 18 5 6-10-5-23 3v11l-47 4-9 17 16-10 31 6 14-5 28 27-12 12-28 18h-17l-9 13-15-3-9 4-8-4-13 8-10 2-3 5-12-2-15 6 20 3 20-9 25-3 34 11 12 8v6l-11 6-10-4-7 7-34-7-15 7-4-3-11 4-9 17 12-13h16l12-5 16 5-34 26-3 9-4 6-7 4 9-1 10-18 24-13 6 2 11-11 23 5v14l-7 3 2 8 11-4 4 2 1 4-10 13 10 5 4-8 14-3 3 6 15-4-6-8 18-12-7-13-27 15-2-16 11-9 14-3 13 22 22 12 11 26-4 9 6 25-2 11-13 1-14 17h-8l-4-9-3 8 8 12-11 11-7-2 2 12-24 27 1 3v-1l7-7 6-3 17-21 16-11 2 6 8-4v6l8-7 4-1v9l20-20-1-3 19-6 5 15-15 41-31 32-39 23-36 29-24 14-15 2-12 13 6 8-5 3-4-9-58 25-21-1-42-9-1-11-57-14 2-15 14-7-6-7-9 9-66 49-8 1 10-19-4-6 9-7 6 1 28-37 1-13 14-6-1-14 13-16-13-19 5-9-2-9-7 9-5-8 8-14 15-3 3-8-8 6-11-3-6 10-2 12-4-9 2-5-2-11-5-2 3 12h-8l-7-7-3 4 16 11 8 26-14 19-14 12-10 2-15-25 2-24-5-7 13-6-16-8-12 1-8 10-4-14-8 13 11 18-27 14-9-15-17 14-23 3-13 10-14 4-13-11 5-45 7-9 17-5-3-7-6 4-6-3-1-12 13-4-4-14-5-2 4-8h5l5-3-7-5 6-15 8 3-2-18 14-7 7-19-3-2-15 18-13 11-8 17-12 13-6 32-7 5 7 9-6 13h-7l5 16-1 15-12 10-10-4-13-18v10l-15-1-3-6-17-6 21 20 7-1 14 5 7 10 3 12-17 3 1 8h-10l-4 4 10 7-5 3-3 6 5 3-14 10 14 12 13-26h6l1-13 18-19 20 11v14l-6 18-33 43v16l8 2-21 15h-41l-12 6-50 2-17 8-29-5 1-8-4-6-5 12-9 9-38-13 11-3-17-10 4 12-1 12-20 13-12-8-11-1 8 9-1 5-8 3-12-6-7 5v9l-13 3-10-5-4 8-17-4-8 10-7-12-24-5 1 8-19-3-5 4-7-21 1-4-10-3-7 6-41-15-15 4-13-6-14 13-17-22 7-8 10 1 10-8-40-17 2-6 27 8 12-5 15 3 5-10 5 1 15-14-12 7-16-3-5 5-7-5-12 2-4-12 4-6 4 1 2-13-17 13-16 7-11-2-17 18-28-2-7 17-21-9-23-1-11 21h13l-24 29-13 11-22 7-16-1-61 25-19-25 5-21 13 5-4-16-9-9v-16l-34-46 9-78-6-17 1 18-17 6 1-15-12-10-8-16 6-11-6-12-9-2 9 12-6 5v38l-5 21-23 2-37-7-5-8-13 5h-8l-12 12-16 9-28 8-3 9-20 17-28 17-41-32-22-47-2-23 7-19-4-6 29-88 6-42-10-78 9-43-2-7 7-25 17-27 14-33 17-31 9-77 14 12 52 106 26 23 17 28-6 12-4 26 1 33 11 26-6 2-9-31-11 2-2 4 13 7-1 38 9 5-1 6-4 1-8-7-3-12-6 4 5 4 5 11-5 6-9-1 8 8 10-6 6 4-17 3-4 8-6-7-2 8 10 4 3-7 14 2 12 18 2 14 3-2 6 11 7-2 3 6-13 20 2 9 13-7 2-13 29-9-21-3-9-10-10 4-5-4-5-10 5-4-1-5-5-2 5-3 29 10 3-17h30l5 8 20 10 42 9 24 17h17l11 8 19 31-19 6-13-9-3 3 16 9 13 12-3-13h12l6 5 7-6 29 3-1 8-10 6 8 15-5 14 10 9 3 15-9 27-18 14 2 18-4 13 4 6 3-11 6 1-2-14 8-15 11-5-2-9 5-4 5 2 17-11 2-17 34 19 6 20-4 6-8-2-5 5 4 7-7 3-2 6 16-7 11-3h12l9 6 20-19 6 1 5 9 3-9 11 1 9-5 3-9-10-3 2-11 9-2 6-6h-7l-12-12-21 6 3-11-12 1-1 5-8 3-5-10 9-24 11-12 9 5-11-17-27 7-1-22 3-16 17-3 1 2-9 5 8 3 4-3 8 1 6 6-5 10 10-9 7-12-12-11-13 1-2 6h-3l7-16 38-9 68-10 23-8 26 12-3 19 7 10v17l9-4-4-2 1-8-2-13 5-2 8 14 4-3 15 8 2 6 4-10-6-6 1-4 11 3-10-12 9-10-1-12-38 11-9-1 72-22 6-6 36-11 13-1 33 24-15 8 8 3 2 23 9-1-5-17 7-7 14 4 14 12 17-9 4 3-1 21 21-22-9-17-11 4-11-2-7 8-19-8 45-5 53-29 75-18 20 8 8-4h9l4 8-21 16 8 7 2-7 14-10 20 13h9l-18-34 1-14-8-11-41 27-4-3 25-15 57-51 32-22 14-5 4 18-6 10 1 8 25-24-23-13 57-45 24 4 6-5 20-1 6-10 20 5 1-10 11-6 5 5 8-7 17-3 6-5-30-4-29 15-8-2-15 1-8 9-12 6-13 4-1-5 17-21 38-35 56-34 48-35 65-27 110-83 39-22 60-16 58-25z",
fillColor: "black",
onHoverColor: "red"
};
element = shallow(React.createElement(Province, __assign({}, componentProps)));
});
afterEach(function () {
onClickProvinceMock.mockReset();
});
it("should render component with proper info", function () {
expect(element.find("[fill=\"black\"]").length).toEqual(1);
expect(element.find("[id=\"PEI\"]").length).toEqual(1);
expect(element.find(".prov-PEI").length).toEqual(1);
});
it("should call `onClick` when the component is clicked", function () {
expect(onClickProvinceMock.mock.calls.length).toEqual(0);
// svg path is nested within empty tag and g tag
element.childAt(0).childAt(0).simulate("click");
expect(onClickProvinceMock.mock.calls.length).toEqual(1);
});
});
//# sourceMappingURL=TestProvince.js.map