{"action":"opened","issue":{"url":"https://api.github.com/repos/alibaba/BizCharts/issues/209","repository_url":"https://api.github.com/repos/alibaba/BizCharts","labels_url":"https://api.github.com/repos/alibaba/BizCharts/issues/209/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/BizCharts/issues/209/comments","events_url":"https://api.github.com/repos/alibaba/BizCharts/issues/209/events","html_url":"https://github.com/alibaba/BizCharts/issues/209","id":304600538,"number":209,"title":"intervalStack: Unable to mount with Enzyme","user":{"login":"devilbags","id":11239869,"avatar_url":"https://avatars3.githubusercontent.com/u/11239869?v=4","gravatar_id":"","url":"https://api.github.com/users/devilbags","html_url":"https://github.com/devilbags","followers_url":"https://api.github.com/users/devilbags/followers","following_url":"https://api.github.com/users/devilbags/following{/other_user}","gists_url":"https://api.github.com/users/devilbags/gists{/gist_id}","starred_url":"https://api.github.com/users/devilbags/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devilbags/subscriptions","organizations_url":"https://api.github.com/users/devilbags/orgs","repos_url":"https://api.github.com/users/devilbags/repos","events_url":"https://api.github.com/users/devilbags/events{/privacy}","received_events_url":"https://api.github.com/users/devilbags/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-13T01:54:11Z","updated_at":"2018-03-13T01:54:11Z","closed_at":null,"author_association":"NONE","body":"When trying to do a full Dom mounting of BizChart (intervalStack), test failed.\r\n\r\nComponent: (This is directly taken from the [demo](https://alibaba.github.io/BizCharts/demo-detail.html?code=demo/pie/innerlabel))\r\n```jsx\r\nconst PieChart = () => {\r\n const data = [\r\n          { item: '事例一', count: 40 },\r\n          { item: '事例二', count: 21 },\r\n          { item: '事例三', count: 17 },\r\n          { item: '事例四', count: 13 },\r\n          { item: '事例五', count: 9 }\r\n        ];\r\n        const dv = new DataView();\r\n        dv.source(data).transform({\r\n          type: 'percent',\r\n          field: 'count',\r\n          dimension: 'item',\r\n          as: 'percent'\r\n        });\r\n        const cols = {\r\n          percent: {\r\n            formatter: val => {\r\n              val = (val * 100) + '%';\r\n              return val;\r\n            }\r\n          }\r\n        }  \r\n  return (\r\n<Chart height={window.innerHeight} data={dv} scale={cols} padding={[ 80, 100, 80, 80 ]} forceFit>\r\n            <Coord type='theta' radius={0.75} />\r\n            <Axis name=\"percent\" />\r\n            <Legend position='right' offsetY={-window.innerHeight / 2 + 120} offsetX={-100} />\r\n            <Tooltip \r\n              showTitle={false} \r\n              itemTpl='<li><span style=\"background-color:{color};\" class=\"g2-tooltip-marker\"></span>{name}: {value}</li>'\r\n              />\r\n            <Geom\r\n              type=\"intervalStack\"\r\n              position=\"percent\"\r\n              color='item'\r\n              tooltip={['item*percent',(item, percent) => {\r\n                percent = percent * 100 + '%';\r\n                return {\r\n                  name: item,\r\n                  value: percent\r\n                };\r\n              }]}\r\n              style={{lineWidth: 1,stroke: '#fff'}}\r\n              >\r\n              <Label content='percent' offset={-40} textStyle={{\r\n                  rotate: 0,\r\n                  textAlign: 'center',\r\n                  shadowBlur: 2,\r\n                  shadowColor: 'rgba(0, 0, 0, .45)'\r\n                }} />\r\n            </Geom>\r\n          </Chart>\r\n)\r\n}\r\nexport default PieChart\r\n```\r\n\r\nTest Code with Enzyme\r\n```js\r\nimport React from 'react'\r\nimport {shallow, mount} from 'enzyme'\r\nimport PieChart from './PieChart'\r\n\r\nit('Shallow rendering works fine of course', () => {\r\n shallow(<PieChart />)\r\n})\r\nit('Mount will fail', () => {\r\n mount(<PieChart />)\r\n})\r\n```\r\n\r\nWhen try to run the above test, below error is observed:\r\n```\r\nTypeError: Cannot read property 'save' of null\r\n\r\nat CText.measureText (node_modules/bizcharts/umd/BizCharts.js:8379:19)\r\n      at CText.calculateBox (node_modules/bizcharts/umd/BizCharts.js:8260:28)\r\n      at CText.getBBox (node_modules/bizcharts/umd/BizCharts.js:1109:24)\r\n      at node_modules/bizcharts/umd/BizCharts.js:6150:32\r\n      at arrayEach (node_modules/bizcharts/umd/BizCharts.js:5053:15)\r\n      at Object.forEach [as each] (node_modules/bizcharts/umd/BizCharts.js:13188:16)\r\n      at Group.getBBox (node_modules/bizcharts/umd/BizCharts.js:6148:16)\r\n      at Category._addItem (node_modules/bizcharts/umd/BizCharts.js:46485:26)\r\n      at node_modules/bizcharts/umd/BizCharts.js:46368:12\r\n      at arrayEach (node_modules/bizcharts/umd/BizCharts.js:24622:9)\r\n      at Object.forEach [as each] (node_modules/bizcharts/umd/BizCharts.js:30743:10)\r\n      at Category._renderItems (node_modules/bizcharts/umd/BizCharts.js:46367:10)\r\n      at Category._renderUI (node_modules/bizcharts/umd/BizCharts.js:46026:12)\r\n      at Category.Group (node_modules/bizcharts/umd/BizCharts.js:5938:14)\r\n      at Category.Base (node_modules/bizcharts/umd/BizCharts.js:28142:52)\r\n      at new Category (node_modules/bizcharts/umd/BizCharts.js:45880:51)\r\n      at Group.addGroup (node_modules/bizcharts/umd/BizCharts.js:6007:21)\r\n      at LegendController._addCategroyLegend (node_modules/bizcharts/umd/BizCharts.js:48537:28)\r\n      at LegendController.addLegend (node_modules/bizcharts/umd/BizCharts.js:48642:23)\r\n      at node_modules/bizcharts/umd/BizCharts.js:34525:32\r\n      at arrayEach (node_modules/bizcharts/umd/BizCharts.js:24622:9)\r\n      at Object.forEach [as each] (node_modules/bizcharts/umd/BizCharts.js:30743:10)\r\n      at node_modules/bizcharts/umd/BizCharts.js:34519:16\r\n      at arrayEach (node_modules/bizcharts/umd/BizCharts.js:24622:9)\r\n      at Object.forEach [as each] (node_modules/bizcharts/umd/BizCharts.js:30743:10)\r\n      at Chart._renderLegends (node_modules/bizcharts/umd/BizCharts.js:34516:14)\r\n      at Chart.drawComponents (node_modules/bizcharts/umd/BizCharts.js:34814:12)\r\n      at Chart.render (node_modules/bizcharts/umd/BizCharts.js:35959:10)\r\n      at Chart.render (node_modules/bizcharts/umd/BizCharts.js:34837:28)\r\n      at Processor.createG2Instance (node_modules/bizcharts/umd/BizCharts.js:52978:13)\r\n      at PureChart.componentDidMount (node_modules/bizcharts/umd/BizCharts.js:51692:37)\r\n      at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:8770:24)\r\n      at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:9946:9)\r\n      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:542:14)\r\n      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)\r\n      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)\r\n      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)\r\n      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)\r\n      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)\r\n      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:581:16)\r\n      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:438:27)\r\n      at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:10050:9)\r\n      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:11017:42)\r\n      at performWork (node_modules/react-dom/cjs/react-dom.development.js:10967:7)\r\n      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:10878:7)\r\n      at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:10732:11)\r\n      at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:10689:12)\r\n      at scheduleTopLevelUpdate (node_modules/react-dom/cjs/react-dom.development.js:11193:5)\r\n      at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:11231:7)\r\n      at node_modules/react-dom/cjs/react-dom.development.js:15226:19\r\n      at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:11102:12)\r\n      at renderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:15225:17)\r\n      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:15290:12)\r\n      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)\r\n      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)\r\n      at mount (node_modules/enzyme/build/mount.js:19:10)\r\n      at Object.it (src/component/eduComponent/genderShare/genderShare.test.js:18:23)\r\n          at new Promise (<anonymous>)\r\n      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)\r\n          at <anonymous>\r\n      at process._tickCallback (internal/process/next_tick.js:160:7)\r\n```"}}
{"actor":{"display_login":"devilbags"}}