charts.jsx 916 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const data = [
  2. [1543276800000, 0],
  3. [1543363200000, 0],
  4. [1543449600000, 36],
  5. [1543536000000, 40],
  6. [1543622400000, 0],
  7. [1543708800000, 17],
  8. [1543795200000, 104],
  9. [1543881600000, 13],
  10. ];
  11. const model = {
  12. _payload: {
  13. batch: [
  14. {
  15. startValue: 1543449600000,
  16. endValue: 1543708800000,
  17. },
  18. ],
  19. },
  20. series: [
  21. {
  22. data,
  23. },
  24. ],
  25. };
  26. export const chart = {
  27. getModel: jest.fn(() => ({option: model})),
  28. };
  29. // eslint-disable-next-line
  30. export const doZoom = (wrapper, chart = chart) => {
  31. wrapper.find('ChartZoom').instance().handleDataZoom({}, chart);
  32. wrapper.find('ChartZoom').instance().handleChartFinished({}, chart);
  33. };
  34. export const mockZoomRange = (startValue, endValue) => {
  35. chart.getModel.mockImplementation(() => ({
  36. ...model,
  37. _payload: {
  38. batch: [
  39. {
  40. startValue,
  41. endValue,
  42. },
  43. ],
  44. },
  45. }));
  46. };