From 73d3507f066b3f8543b548b7ac1a0388cacca2ca Mon Sep 17 00:00:00 2001 From: svonderohe Date: Thu, 5 Dec 2024 08:45:58 -0700 Subject: [PATCH 1/2] Fix "Cannot set properties of null (setting 'hoverState')" --- src/chart/line/LineView.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index deebe66e22..18b49f81a8 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -1031,7 +1031,6 @@ class LineView extends ChartView { _changePolyState(toState: DisplayState) { const polygon = this._polygon; - setStatesFlag(this._polyline, toState); polygon && setStatesFlag(polygon, toState); } From b9614d46fcce8f58f04802e357175caad0a3d2c3 Mon Sep 17 00:00:00 2001 From: svonderohe Date: Fri, 6 Dec 2024 08:51:16 -0700 Subject: [PATCH 2/2] Add tests for _changePolyState change --- test/ut/jest.config.cjs | 1 + test/ut/spec/chart/line/LineView.test.ts | 26 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/ut/spec/chart/line/LineView.test.ts diff --git a/test/ut/jest.config.cjs b/test/ut/jest.config.cjs index 5ca8031953..dd20b717d6 100644 --- a/test/ut/jest.config.cjs +++ b/test/ut/jest.config.cjs @@ -42,6 +42,7 @@ module.exports = { testMatch: [ '**/spec/api/*.test.ts', '**/spec/component/**/*.test.ts', + '**/spec/chart/**/*.test.ts', '**/spec/series/**/*.test.ts', '**/spec/data/*.test.ts', '**/spec/model/*.test.ts', diff --git a/test/ut/spec/chart/line/LineView.test.ts b/test/ut/spec/chart/line/LineView.test.ts new file mode 100644 index 0000000000..d7e77585fe --- /dev/null +++ b/test/ut/spec/chart/line/LineView.test.ts @@ -0,0 +1,26 @@ +import LineView from "@/src/chart/line/LineView"; +import { HOVER_STATE_EMPHASIS } from "@/src/util/states"; +import { ECElement } from "@/src/util/types"; + +describe('LineView', function () { + + let lineView: LineView; + beforeEach(function () { + lineView = new LineView(); + lineView.init(); + }); + + it('should change poly state when polygon is set', function () { + lineView._polygon = lineView._newPolygon( + [], [], + ); + lineView._changePolyState('emphasis'); + expect((lineView._polygon as ECElement).hoverState).toBe(HOVER_STATE_EMPHASIS); + }); + + it('should not error on state change when polygon is not set', function () { + lineView._polygon = null; + expect(() => lineView._changePolyState('emphasis')).not.toThrow(); + }); + +});