Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jun 23, 2021
1 parent b8dd20f commit c791316
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions panel/tests/pane/test_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np

from panel.models.plotly import PlotlyPlot
from panel.layout import Tabs
from panel.pane import PaneBase, Plotly


Expand Down Expand Up @@ -181,3 +182,32 @@ def test_plotly_autosize(document, comm):
model.sizing_mode == 'fixed'

pane._cleanup(model)


@plotly_available
def test_plotly_tabs(document, comm):
trace = go.Scatter(x=[0, 1], y=[2, 3])

pane1 = Plotly(dict(data=[trace], layout={'autosize': True}))
pane2 = Plotly(dict(data=[trace], layout={'autosize': True}))

tabs = Tabs(pane1, pane2)

root = tabs.get_root(document, comm)

model1 = pane1._models[root.id][0]
model2 = pane2._models[root.id][0]

cb1, cb2 = root.js_property_callbacks['change:active']
if cb1.args['model'] is model2:
cb1, cb2 = cb2, cb1
assert model1.visible
assert cb1.args['model'] is model1
assert cb1.args['i'] == 0
assert not model2.visible
assert cb2.args['model'] is model2
assert cb2.args['i'] == 1

tabs.insert(0, 'Blah')
assert cb1.args['i'] == 1
assert cb2.args['i'] == 2

0 comments on commit c791316

Please sign in to comment.