| 519 | afterEach(destroyGraphDiv); |
| 520 | |
| 521 | function run(spec) { |
| 522 | gd = createGraphDiv(); |
| 523 | |
| 524 | var data = (spec.traces || [{}]).map(function (t) { |
| 525 | t.type = 'sunburst'; |
| 526 | if (!t.labels) t.labels = labels0.slice(); |
| 527 | if (!t.parents) t.parents = parents0.slice(); |
| 528 | return t; |
| 529 | }); |
| 530 | |
| 531 | var layout = Lib.extendFlat( |
| 532 | { |
| 533 | width: 500, |
| 534 | height: 500, |
| 535 | margin: { t: 0, b: 0, l: 0, r: 0, pad: 0 } |
| 536 | }, |
| 537 | spec.layout || {} |
| 538 | ); |
| 539 | |
| 540 | var exp = spec.exp || {}; |
| 541 | var ptData = null; |
| 542 | |
| 543 | return Plotly.newPlot(gd, data, layout) |
| 544 | .then(function () { |
| 545 | gd.once('plotly_hover', function (d) { |
| 546 | ptData = d.points[0]; |
| 547 | }); |
| 548 | }) |
| 549 | .then(hover(gd, spec.pos)) |
| 550 | .then(function () { |
| 551 | assertHoverLabelContent(exp.label); |
| 552 | |
| 553 | for (var k in exp.ptData) { |
| 554 | expect(ptData[k]).toBe(exp.ptData[k], 'pt event data key ' + k); |
| 555 | } |
| 556 | |
| 557 | expect(typeof ptData.bbox).toEqual('object'); |
| 558 | expect(typeof ptData.bbox.x0).toEqual('number'); |
| 559 | expect(typeof ptData.bbox.x1).toEqual('number'); |
| 560 | expect(typeof ptData.bbox.y0).toEqual('number'); |
| 561 | expect(typeof ptData.bbox.y1).toEqual('number'); |
| 562 | |
| 563 | if (exp.style) { |
| 564 | var gd3 = d3Select(gd); |
| 565 | assertHoverLabelStyle(gd3.select('.hovertext'), exp.style); |
| 566 | } |
| 567 | }); |
| 568 | } |
| 569 | |
| 570 | [ |
| 571 | { |