Skip to content

Commit 6478aa6

Browse files
committed
add tests for js
1 parent e18b555 commit 6478aa6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

jupyter_sphinx/execute.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ def cell_output_to_nodes(cell, data_priority, dir):
405405
)
406406
except StopIteration:
407407
continue
408-
409408
data = output['data'][mime_type]
410409
if mime_type.startswith('image'):
411410
# Sphinx treats absolute paths as being rooted at the source

tests/test_execute.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from sphinx.testing.util import SphinxTestApp, path
88
from sphinx.errors import ExtensionError
9+
from docutils.nodes import raw
910

1011
import pytest
1112

@@ -177,3 +178,16 @@ def test_widgets(doctree):
177178
tree = doctree(source)
178179
assert len(list(tree.traverse(JupyterWidgetViewNode))) == 1
179180
assert len(list(tree.traverse(JupyterWidgetStateNode))) == 1
181+
182+
183+
def test_javascript(doctree):
184+
source = '''
185+
.. jupyter-execute::
186+
187+
from IPython.display import display_javascript, Javascript
188+
Javascript('window.alert("Hello world!")')
189+
'''
190+
tree = doctree(source)
191+
node, = list(tree.traverse(raw))
192+
text, = node.children
193+
assert 'world' in text

0 commit comments

Comments
 (0)