| 626 | afterEach(destroyGraphDiv); |
| 627 | |
| 628 | function run(spec) { |
| 629 | gd = createGraphDiv(); |
| 630 | |
| 631 | var data = (spec.traces || [{}]).map(function (t) { |
| 632 | t.type = 'treemap'; |
| 633 | if (!t.labels) t.labels = labels0.slice(); |
| 634 | if (!t.parents) t.parents = parents0.slice(); |
| 635 | return t; |
| 636 | }); |
| 637 | |
| 638 | var layout = Lib.extendFlat( |
| 639 | { |
| 640 | width: 500, |
| 641 | height: 500, |
| 642 | margin: { t: 0, b: 0, l: 0, r: 0, pad: 0 } |
| 643 | }, |
| 644 | spec.layout || {} |
| 645 | ); |
| 646 | |
| 647 | var exp = spec.exp || {}; |
| 648 | var ptData = null; |
| 649 | |
| 650 | return Plotly.newPlot(gd, data, layout) |
| 651 | .then(function () { |
| 652 | gd.once('plotly_hover', function (d) { |
| 653 | ptData = d.points[0]; |
| 654 | }); |
| 655 | }) |
| 656 | .then(hover(gd, spec.pos)) |
| 657 | .then(function () { |
| 658 | assertHoverLabelContent(exp.label); |
| 659 | |
| 660 | for (var k in exp.ptData) { |
| 661 | expect(ptData[k]).toBe(exp.ptData[k], 'pt event data key ' + k); |
| 662 | } |
| 663 | |
| 664 | expect(typeof ptData.bbox).toEqual('object'); |
| 665 | expect(typeof ptData.bbox.x0).toEqual('number'); |
| 666 | expect(typeof ptData.bbox.x1).toEqual('number'); |
| 667 | expect(typeof ptData.bbox.y0).toEqual('number'); |
| 668 | expect(typeof ptData.bbox.y1).toEqual('number'); |
| 669 | |
| 670 | if (exp.style) { |
| 671 | var gd3 = d3Select(gd); |
| 672 | assertHoverLabelStyle(gd3.select('.hovertext'), exp.style); |
| 673 | } |
| 674 | }); |
| 675 | } |
| 676 | |
| 677 | [ |
| 678 | { |