grafana/public/app/plugins/panel/geomap/style/utils.test.ts
Ashley Harrison d33b4918cd
Chore: more any/type assertion improvements (#59229)
more any/type assertion improvements
2022-11-23 16:54:57 +00:00

56 lines
1.3 KiB
TypeScript

import { ResourceDimensionMode } from 'app/features/dimensions';
import { StyleConfig } from './types';
import { getStyleConfigState } from './utils';
describe('style utils', () => {
it('should fill in default values', async () => {
const cfg: StyleConfig = {
color: {
field: 'Price',
fixed: 'dark-green',
},
opacity: 0.4,
size: {
field: 'Count',
fixed: 5,
max: 15,
min: 2,
},
symbol: {
fixed: 'img/icons/marker/star.svg',
mode: ResourceDimensionMode.Fixed, // 'fixed',
},
textConfig: {
fontSize: 12,
offsetX: 0,
offsetY: 0,
// textAlign: 'center',
// textBaseline: 'middle',
},
};
const state = await getStyleConfigState(cfg);
state.config = null as unknown as StyleConfig; // not interesting in the snapshot
expect(state.hasText).toBe(false);
expect(state).toMatchInlineSnapshot(`
Object {
"base": Object {
"color": "#37872D",
"lineWidth": 1,
"opacity": 0.4,
"rotation": 0,
"size": 5,
},
"config": null,
"fields": Object {
"color": "Price",
"size": "Count",
},
"hasText": false,
"maker": [Function],
}
`);
});
});