utils.test.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { ResourceDimensionMode } from 'app/features/dimensions';
  2. import { StyleConfig } from './types';
  3. import { getStyleConfigState } from './utils';
  4. describe('style utils', () => {
  5. it('should fill in default values', async () => {
  6. const cfg: StyleConfig = {
  7. color: {
  8. field: 'Price',
  9. fixed: 'dark-green',
  10. },
  11. opacity: 0.4,
  12. size: {
  13. field: 'Count',
  14. fixed: 5,
  15. max: 15,
  16. min: 2,
  17. },
  18. symbol: {
  19. fixed: 'img/icons/marker/star.svg',
  20. mode: ResourceDimensionMode.Fixed, // 'fixed',
  21. },
  22. textConfig: {
  23. fontSize: 12,
  24. offsetX: 0,
  25. offsetY: 0,
  26. // textAlign: 'center',
  27. // textBaseline: 'middle',
  28. },
  29. };
  30. const state = await getStyleConfigState(cfg);
  31. state.config = null as any; // not interesting in the snapshot
  32. expect(state.hasText).toBe(false);
  33. expect(state).toMatchInlineSnapshot(`
  34. Object {
  35. "base": Object {
  36. "color": "#37872D",
  37. "lineWidth": 1,
  38. "opacity": 0.4,
  39. "rotation": 0,
  40. "size": 5,
  41. },
  42. "config": null,
  43. "fields": Object {
  44. "color": "Price",
  45. "size": "Count",
  46. },
  47. "hasText": false,
  48. "maker": [Function],
  49. }
  50. `);
  51. });
  52. });