Skip to content

Commit

Permalink
Update tests to reflect new capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
rdewit committed Oct 15, 2020
1 parent fe74b58 commit 9b7c94e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion data/olStyles/polygon_transparentpolygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import OlStyleFill from 'ol/style/Fill';

const olPolygonTransparentPolygon = new OlStyle({
stroke: new OlStyleStroke({
color: '#FFFFFF'
color: 'rgba(255,255,255,0.7)',
lineDash: [10, 15],
width: 2
}),
fill: new OlStyleFill({
color: 'rgba(0,0,128,0.5)'
Expand Down
5 changes: 4 additions & 1 deletion data/styles/polygon_transparentpolygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const polygonTransparentPolygon: Style = {
kind: 'Fill',
color: '#000080',
opacity: 0.5,
outlineColor: '#FFFFFF'
outlineColor: '#ffffff',
outlineDasharray: [10, 15],
outlineOpacity: 0.7,
outlineWidth: 2
}]
}
]
Expand Down
17 changes: 11 additions & 6 deletions src/OlStyleParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,22 +808,27 @@ describe('OlStyleParser implements StyleParser', () => {
});
});
it('can write a OpenLayers PolygonSymbolizer', () => {
expect.assertions(5);
expect.assertions(6);
return styleParser.writeStyle(polygon_transparentpolygon)
.then((olStyle: OlStyle) => {
expect(olStyle).toBeDefined();

const expecSymb = polygon_transparentpolygon.rules[0].symbolizers[0] as FillSymbolizer;
const olStroke = olStyle.getStroke();

expect(olStroke).toBeDefined();
expect(olStroke.getColor()).toEqual(expecSymb.outlineColor);

const expecSymbOutlCol: string = expecSymb.outlineColor as string;
const expecSymbOutlOpac: number = expecSymb.outlineOpacity as number;
expect(olStroke.getColor()).toEqual(OlStyleUtil.getRgbaColor(expecSymbOutlCol, expecSymbOutlOpac));

const olFill = olStyle.getFill();
expect(olFill).toBeDefined();
const expecSymbCol: string = expecSymb.color as string;
const expecSymbOpac: number = expecSymb.opacity as number;
expect(olFill.getColor()).toEqual(OlStyleUtil.getRgbaColor(expecSymbCol, expecSymbOpac));

const expecSymbFillCol: string = expecSymb.color as string;
const expecSymbFillOpac: number = expecSymb.opacity as number;
expect(olFill.getColor()).toEqual(OlStyleUtil.getRgbaColor(expecSymbFillCol, expecSymbFillOpac));

expect(olStroke.getLineDash()).toEqual(expecSymb.outlineDasharray);
});
});
it('can write a OpenLayers TextSymbolizer', () => {
Expand Down

0 comments on commit 9b7c94e

Please sign in to comment.