From f51fcdea377c18985cf3a97cc964b7f9f49e0f8d Mon Sep 17 00:00:00 2001 From: Matteo Velludini Date: Mon, 16 Jul 2018 11:36:43 +0200 Subject: [PATCH] fix text font on firefox, updated tests --- .../components/map/openlayers/VectorStyle.js | 4 ++-- web/client/components/style/TextStyler.jsx | 8 ++++---- web/client/reducers/__tests__/mapInfo-test.js | 4 ++-- .../selectors/__tests__/annotations-test.js | 20 +++++++++---------- web/client/selectors/annotations.js | 1 + web/client/test-resources/Annotation.json | 6 +++--- web/client/utils/AnnotationsUtils.js | 6 +++--- .../utils/__tests__/AnnotationsUtils-test.js | 17 +++++++--------- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/web/client/components/map/openlayers/VectorStyle.js b/web/client/components/map/openlayers/VectorStyle.js index ec51973c44..e873d6f456 100644 --- a/web/client/components/map/openlayers/VectorStyle.js +++ b/web/client/components/map/openlayers/VectorStyle.js @@ -123,9 +123,9 @@ const STYLE_TEXT = { fontStyle: 'normal', fontSize: '14', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: "14px FontAwesome", + font: "14px Arial", textAlign: 'center', color: '#000000', opacity: 1 diff --git a/web/client/components/style/TextStyler.jsx b/web/client/components/style/TextStyler.jsx index dd54eba1d9..78b930ff20 100644 --- a/web/client/components/style/TextStyler.jsx +++ b/web/client/components/style/TextStyler.jsx @@ -44,13 +44,13 @@ class TextStyler extends React.Component { fontWeightValues: [{value: "normal"}, {value: "bold"}], alignValues: [{value: "start", label: "left"}, {value: "center", label: "center"}, {value: "end", label: "right"}], fontStyleValues: [{value: "normal"}, {value: "italic"}], - fontFamilyValues: [{value: "Arial"}, {value: "FontAwesome"}, {value: "Courier"}], + fontFamilyValues: [{value: "Arial"}, {value: "Helvetica"}, {value: "sans-serif"}, {value: "Courier"}], shapeStyle: {}, setStyleParameter: () => {} }; state = { - fontFamily: "FontAwesome" + fontFamily: "Arial" }; render() { @@ -98,7 +98,7 @@ class TextStyler extends React.Component { { let fontFamily = e.value ? e.value : e; if (fontFamily === "") { - fontFamily = "FontAwesome"; + fontFamily = "Arial"; } this.setState({fontFamily}); const font = createFont({...style, fontFamily}); diff --git a/web/client/reducers/__tests__/mapInfo-test.js b/web/client/reducers/__tests__/mapInfo-test.js index 5f457e2da1..843aa56a9c 100644 --- a/web/client/reducers/__tests__/mapInfo-test.js +++ b/web/client/reducers/__tests__/mapInfo-test.js @@ -1356,9 +1356,9 @@ describe('Test the mapInfo reducer', () => { fontStyle: 'normal', fontSize: '14', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: '14px FontAwesome', + font: '14px Arial', textAlign: 'center', color: '#000000', opacity: 1 diff --git a/web/client/selectors/__tests__/annotations-test.js b/web/client/selectors/__tests__/annotations-test.js index 117d5ccf11..f7b6b1c7fe 100644 --- a/web/client/selectors/__tests__/annotations-test.js +++ b/web/client/selectors/__tests__/annotations-test.js @@ -245,7 +245,7 @@ const state = { } }, Text: { - font: '14px FontAwesome', + font: '14px Arial', color: '#1726E6', weight: 1, opacity: 1 @@ -285,9 +285,9 @@ const state = { fontStyle: 'normal', fontSize: '21', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: 'normal normal 21px FontAwesome', + font: 'normal normal 21px Arial', textAlign: 'center', color: '#A424C0', opacity: 1 @@ -381,9 +381,9 @@ const state = { fontStyle: 'normal', fontSize: '21', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: 'normal normal 21px FontAwesome', + font: 'normal normal 21px Arial', textAlign: 'center', color: '#A424C0', opacity: 1 @@ -402,9 +402,9 @@ const state = { fontStyle: 'normal', fontSize: '21', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: 'normal normal 21px FontAwesome', + font: 'normal normal 21px Arial', textAlign: 'center', color: '#A424C0', opacity: 1 @@ -523,13 +523,13 @@ describe('Test annotations selectors', () => { expect(retVal.filter).toBe(''); }); - it('test annotationsListSelector', () => { + it('test aeronauticalOptionsSelector', () => { const retVal = aeronauticalOptionsSelector(state); expect(retVal).toBe(undefined); }); - it('test annotationsListSelector with true value', () => { - const retVal = aeronauticalOptionsSelector({...state, aeronauticalOptions: true}); + it('test aeronauticalOptionsSelector with true value', () => { + const retVal = aeronauticalOptionsSelector({annotations: {aeronauticalOptions: true}}); expect(retVal).toBe(true); }); diff --git a/web/client/selectors/annotations.js b/web/client/selectors/annotations.js index 168b9b46a9..9a05050de9 100644 --- a/web/client/selectors/annotations.js +++ b/web/client/selectors/annotations.js @@ -106,6 +106,7 @@ const annotationSelector = createSelector([annotationsListSelector], (annotation module.exports = { annotationsLayerSelector, annotationsInfoSelector, + aeronauticalOptionsSelector, annotationsSelector, annotationsListSelector, annotationSelector, diff --git a/web/client/test-resources/Annotation.json b/web/client/test-resources/Annotation.json index 4909d41e21..45f6996395 100644 --- a/web/client/test-resources/Annotation.json +++ b/web/client/test-resources/Annotation.json @@ -2311,8 +2311,8 @@ }, "Text": { "color": "#000000", - "font": "14px FontAwesome", - "fontFamily": "FontAwesome", + "font": "14px Arial", + "fontFamily": "Arial", "fontSize": "14", "fontSizeUom": "px", "fontStyle": "normal", @@ -2324,4 +2324,4 @@ "type": "GeometryCollection" }, "type": "Feature" -} \ No newline at end of file +} diff --git a/web/client/utils/AnnotationsUtils.js b/web/client/utils/AnnotationsUtils.js index 3d173ee985..3d85636234 100644 --- a/web/client/utils/AnnotationsUtils.js +++ b/web/client/utils/AnnotationsUtils.js @@ -32,9 +32,9 @@ const STYLE_TEXT = { fontStyle: 'normal', fontSize: '14', fontSizeUom: 'px', - fontFamily: 'FontAwesome', + fontFamily: 'Arial', fontWeight: 'normal', - font: "14px FontAwesome", + font: "14px Arial", textAlign: 'center', color: '#000000', opacity: 1 @@ -273,7 +273,7 @@ const AnnotationsUtils = { * it converts some props of a CSS-font into a shorhand form * @return {string} a CSS-font */ - createFont: ({fontSize = "14", fontSizeUom = "px", fontFamily = "FontAwesome", fontStyle = "normal", fontWeight = "normal"} = {}) => { + createFont: ({fontSize = "14", fontSizeUom = "px", fontFamily = "Arial", fontStyle = "normal", fontWeight = "normal"} = {}) => { return `${fontStyle} ${fontWeight} ${fontSize}${fontSizeUom} ${fontFamily}`; }, /** diff --git a/web/client/utils/__tests__/AnnotationsUtils-test.js b/web/client/utils/__tests__/AnnotationsUtils-test.js index 6ea68fc5e7..0c5f24ada8 100644 --- a/web/client/utils/__tests__/AnnotationsUtils-test.js +++ b/web/client/utils/__tests__/AnnotationsUtils-test.js @@ -139,12 +139,12 @@ describe('Test the AnnotationsUtils', () => { expect(textParams.length).toBe(9); const {font, color, opacity, fontStyle, fontSize, fontSizeUom, textAlign, fontFamily, fontWeight} = DEFAULT_ANNOTATIONS_STYLES.Text; - expect(font).toBe("14px FontAwesome"); + expect(font).toBe("14px Arial"); expect(color).toBe("#000000"); expect(fontStyle).toBe("normal"); expect(fontWeight).toBe("normal"); expect(fontSize).toBe("14"); - expect(fontFamily).toBe("FontAwesome"); + expect(fontFamily).toBe("Arial"); expect(fontSizeUom).toBe("px"); expect(textAlign).toBe("center"); expect(opacity).toBe(1); @@ -250,16 +250,14 @@ describe('Test the AnnotationsUtils', () => { }); it('create font with values', () => { // with defaults - expect(createFont({})).toBe("normal normal 14px FontAwesome"); - + expect(createFont({})).toBe("normal normal 14px Arial"); // with values expect(createFont({fontFamily: "Courier"})).toBe("normal normal 14px Courier"); - expect(createFont({fontSize: "30"})).toBe("normal normal 30px FontAwesome"); - expect(createFont({fontSizeUom: "em"})).toBe("normal normal 14em FontAwesome"); - expect(createFont({fontStyle: "italic"})).toBe("italic normal 14px FontAwesome"); - expect(createFont({fontWeight: "bold"})).toBe("normal bold 14px FontAwesome"); + expect(createFont({fontSize: "30"})).toBe("normal normal 30px Arial"); + expect(createFont({fontSizeUom: "em"})).toBe("normal normal 14em Arial"); + expect(createFont({fontStyle: "italic"})).toBe("italic normal 14px Arial"); + expect(createFont({fontWeight: "bold"})).toBe("normal bold 14px Arial"); }); - it('circlesToMultiPolygon', () => { const {geometry, properties, style} = feature; const f = circlesToMultiPolygon(geometry, properties, style.Circle); @@ -269,7 +267,6 @@ describe('Test the AnnotationsUtils', () => { expect(f.properties).toExist(); expect(f.properties.ms_style).toExist(); expect(f.properties.ms_style.strokeColor).toBe(style.Circle.color); - }); it('fromCircleToPolygon', () => { const {geometry, properties} = circle1;