summaryrefslogtreecommitdiff
path: root/tests/test_domain_js.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-04-23 01:02:29 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-04-23 16:31:33 +0900
commit96fa6d2972ea7c77525607ec490daed9e303535d (patch)
tree610c22b6788db2b6c5449cf4819fa5ac190e30d6 /tests/test_domain_js.py
parentdb377ceb5524ec276ac6d18ed3206b8147800ae7 (diff)
downloadsphinx-git-96fa6d2972ea7c77525607ec490daed9e303535d.tar.gz
Implement get_full_qualified_name() to JavascriptDomain (refs: #3630)
Diffstat (limited to 'tests/test_domain_js.py')
-rw-r--r--tests/test_domain_js.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_domain_js.py b/tests/test_domain_js.py
index e521d00c3..a3915c563 100644
--- a/tests/test_domain_js.py
+++ b/tests/test_domain_js.py
@@ -10,7 +10,11 @@
"""
import pytest
+from mock import Mock
+from docutils import nodes
+
from sphinx import addnodes
+from sphinx.domains.javascript import JavaScriptDomain
from util import assert_node
@@ -133,3 +137,31 @@ def test_domain_js_find_obj(app, status, warning):
( u'module_a.submodule.ModTopLevel.mod_child_2', (u'module', u'method')))
assert (find_obj(u'module_b.submodule', u'ModTopLevel', u'module_a.submodule', u'mod') ==
( u'module_a.submodule', (u'module', u'module')))
+
+
+def test_get_full_qualified_name():
+ env = Mock(domaindata={})
+ domain = JavaScriptDomain(env)
+
+ # non-js references
+ node = nodes.reference()
+ assert domain.get_full_qualified_name(node) is None
+
+ # simple reference
+ node = nodes.reference(reftarget='func')
+ assert domain.get_full_qualified_name(node) == 'func'
+
+ # with js:module context
+ kwargs = {'js:module': 'module1'}
+ node = nodes.reference(reftarget='func', **kwargs)
+ assert domain.get_full_qualified_name(node) == 'module1.func'
+
+ # with js:object context
+ kwargs = {'js:object': 'Class'}
+ node = nodes.reference(reftarget='func', **kwargs)
+ assert domain.get_full_qualified_name(node) == 'Class.func'
+
+ # with both js:module and js:object context
+ kwargs = {'js:module': 'module1', 'js:object': 'Class'}
+ node = nodes.reference(reftarget='func', **kwargs)
+ assert domain.get_full_qualified_name(node) == 'module1.Class.func'