@woosmap/ui 3.89.0 → 3.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Icon/Icon.js +2 -1
- package/src/components/Icon/Icon.stories.js +1 -0
- package/src/components/Icon/Icon.test.js +10 -0
- package/src/components/Map/drawOnMap.js +1 -39
- package/src/components/ServiceMessage/ServiceMessage.js +1 -1
- package/src/components/ServiceMessage/ServiceMessage.test.js +28 -11
package/package.json
CHANGED
|
@@ -426,7 +426,8 @@ const Icons = {
|
|
|
426
426
|
class Icon extends Component {
|
|
427
427
|
render() {
|
|
428
428
|
const { icon, size, className, title, testId } = this.props;
|
|
429
|
-
const IconComponent = Icons[icon];
|
|
429
|
+
const IconComponent = Object.keys(Icons).includes(icon) ? Icons[icon] : Woosmap;
|
|
430
|
+
|
|
430
431
|
return (
|
|
431
432
|
<IconComponent
|
|
432
433
|
className={cl('icon', className)}
|
|
@@ -32,3 +32,4 @@ export const All = () => <div className="flex-wrap">{Object.keys(Icons).map(draw
|
|
|
32
32
|
export const Website = () => <div className="flex-wrap">{Object.keys(WebsiteIcons).map(drawIcon)}</div>;
|
|
33
33
|
export const Console = () => <div className="flex-wrap">{Object.keys(ConsoleIcons).map(drawIcon)}</div>;
|
|
34
34
|
export const Products = () => <div className="flex-wrap">{Object.keys(ProductsIcons).map(drawIcon)}</div>;
|
|
35
|
+
export const NotExisting = () => <div className="flex-wrap">{drawIcon('not-existing-icon')}</div>;
|
|
@@ -40,3 +40,13 @@ it('renders all icon components', () => {
|
|
|
40
40
|
const { Icons } = Icon;
|
|
41
41
|
Object.keys(Icons).forEach(isIconRendered);
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
it('renders woosmap icon component when using bad icon name', () => {
|
|
45
|
+
const { getByTestId } = render(<Icon icon="no-existing-icon" size={64} />);
|
|
46
|
+
|
|
47
|
+
const result = getByTestId('icon-no-existing-icon');
|
|
48
|
+
|
|
49
|
+
expect(result).toHaveClass('icon');
|
|
50
|
+
expect(result).toHaveAttribute('width', '64');
|
|
51
|
+
expect(result).toHaveTextContent('woosmap');
|
|
52
|
+
});
|
|
@@ -86,45 +86,7 @@ export const woosmapBoundsFromViewport = function woosmapBoundsFromViewport(view
|
|
|
86
86
|
|
|
87
87
|
export const createWoosmapMap = (node) => {
|
|
88
88
|
try {
|
|
89
|
-
return new window.woosmap.map.Map(node
|
|
90
|
-
styles: [
|
|
91
|
-
{
|
|
92
|
-
featureType: 'administrative',
|
|
93
|
-
elementType: 'all',
|
|
94
|
-
stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 20 }],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
featureType: 'road',
|
|
98
|
-
elementType: 'all',
|
|
99
|
-
stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 40 }],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
featureType: 'water',
|
|
103
|
-
elementType: 'all',
|
|
104
|
-
stylers: [{ visibility: 'on' }, { saturation: -10 }, { lightness: 30 }],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
featureType: 'landscape.man_made',
|
|
108
|
-
elementType: 'all',
|
|
109
|
-
stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 10 }],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
featureType: 'landscape.natural',
|
|
113
|
-
elementType: 'all',
|
|
114
|
-
stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 60 }],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
featureType: 'poi',
|
|
118
|
-
elementType: 'all',
|
|
119
|
-
stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
featureType: 'transit',
|
|
123
|
-
elementType: 'all',
|
|
124
|
-
stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
});
|
|
89
|
+
return new window.woosmap.map.Map(node);
|
|
128
90
|
} catch (e) {
|
|
129
91
|
console.error('Cound not instantiate a Map');
|
|
130
92
|
console.error(e);
|
|
@@ -42,6 +42,6 @@ ServiceMessage.defaultProps = {
|
|
|
42
42
|
|
|
43
43
|
ServiceMessage.propTypes = {
|
|
44
44
|
type: PropTypes.oneOf([undefined, 'success', 'error', 'warning', 'info']),
|
|
45
|
-
text: PropTypes.string,
|
|
45
|
+
text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
46
46
|
testId: PropTypes.string,
|
|
47
47
|
};
|
|
@@ -4,16 +4,33 @@ import { act } from 'react-dom/test-utils';
|
|
|
4
4
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
5
|
import ServiceMessage from './ServiceMessage';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
describe('<ServiceMessage />', () => {
|
|
8
|
+
it('renders a ServiceMessage component ', () => {
|
|
9
|
+
const ref = React.createRef();
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<div>
|
|
12
|
+
<ServiceMessage text="my message" ref={ref} />
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
act(() => {
|
|
16
|
+
ref.current.open();
|
|
17
|
+
});
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
expect(container.firstChild).toHaveTextContent('my message');
|
|
20
|
+
});
|
|
21
|
+
it('does not throw a proptype error if text is node', () => {
|
|
22
|
+
const ref = React.createRef();
|
|
23
|
+
const errorSpy = jest.spyOn(console, 'error');
|
|
24
|
+
const warnSpy = jest.spyOn(console, 'warn');
|
|
25
|
+
render(
|
|
26
|
+
<div>
|
|
27
|
+
<ServiceMessage text={<div>Some node</div>} ref={ref} />
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
act(() => {
|
|
31
|
+
ref.current.open();
|
|
32
|
+
});
|
|
33
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
34
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
35
|
+
});
|
|
19
36
|
});
|