Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('generates getLegendGraphicUrl if no "legendUrl" configured (extraParams)', () => {
const extraParams = {
HEIGHT: 400,
WIDTH: 400,
LANGUAGE: 'de'
};
const wrapper = TestUtil.mountComponent(Legend, {
layer: layer1,
extraParams: extraParams
});
const img = wrapper.find('img').getElement();
const legendUrl = MapUtil.getLegendGraphicUrl(layer1, extraParams);
expect(img.props.src).toBe(legendUrl);
});
it('generates getLegendGraphicUrl if no "legendUrl" configured', () => {
const wrapper = TestUtil.mountComponent(Legend, {layer: layer1});
const img = wrapper.find('img').getElement();
const legendUrl = MapUtil.getLegendGraphicUrl(layer1);
expect(img.props.src).toBe(legendUrl);
});
getLegendUrl(layer: OlLayer, extraParams: any) {
let legendUrl;
if (layer.get('legendUrl')) {
legendUrl = layer.get('legendUrl');
} else {
legendUrl = MapUtil.getLegendGraphicUrl(layer, extraParams);
}
return legendUrl;
}