Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
tests/typescript: Add end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tavian Barnes committed Oct 1, 2019
1 parent 886a5fd commit 40b3e7b
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 14 deletions.
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/test_typescript/source/docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
extensions = [
'sphinx_js'
]

# Minimal stuff needed for Sphinx to work:
js_language = 'typescript'
jsdoc_config_path = '../tsconfig.json'
source_suffix = '.rst'
master_doc = 'index'
author = u'Tavian Barnes'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
Empty file.
1 change: 1 addition & 0 deletions tests/test_typescript/source/docs/overload.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. js:autofunction:: overloaded
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/test_typescript/source/overload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* An overloaded function (1).
*/
function overloaded(arg: number): number;

/**
* An overloaded function (2).
*/
function overloaded(arg: string): string;

function overloaded(arg: number | string): number | string {
return arg;
}
8 changes: 8 additions & 0 deletions tests/test_typescript/source/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5"
},
"include": [
"*.ts"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
from sphinx_js.doclets import program_name_on_this_platform
from sphinx_js.typedoc import TypeDoc, parse_typedoc

from tests.testing import SphinxBuildTestCase


class Tests(TestCase):
"""Test typedoc to jsdoc conversion on typescript/*.ts
"""
@classmethod
def setup_class(cls):
cls.source_dir = os.path.join(os.path.dirname(__file__), 'typescript')
cls.source_dir = os.path.join(os.path.dirname(__file__), 'source')
cls.tmpdir = mkdtemp()

@classmethod
Expand Down Expand Up @@ -63,3 +65,16 @@ def test_references(self):
with open(jsdoc_ref_file, 'r') as jsdocfile:
jsdoc_ref = json.load(jsdocfile)
eq_(jsdoc, jsdoc_ref)


class BuildTests(SphinxBuildTestCase):
def test_overloads(self):
"""Make sure we correctly render overloaded typescript functions."""
self._file_contents_eq(
'overload',
'overloaded(arg)\n\n'
' An overloaded function (1).\n\n'
' Arguments:\n'
' * **arg** (*number*) --\n\n'
' Returns:\n'
' **number** --\n')
13 changes: 0 additions & 13 deletions tests/typescript/overload.ts

This file was deleted.

0 comments on commit 40b3e7b

Please sign in to comment.