From 8f76d7db03c5f88fd7060f7dd48731a2a5501db0 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 1 May 2016 01:17:34 +0200 Subject: [PATCH] test,tools: test yaml parsing of doctool Add checks that make sure the doctool parses metadata correctly. PR-URL: https://github.com/nodejs/node/pull/6495 Reviewed-By: Robert Jefe Lindstaedt Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- test/doctool/test-doctool-html.js | 20 +++++++++++++ test/doctool/test-doctool-json.js | 47 +++++++++++++++++++++++++++++++ test/fixtures/doc_with_yaml.md | 21 ++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 test/fixtures/doc_with_yaml.md diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index afd89489f11ed4..7aa88414515681 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -27,6 +27,26 @@ const testData = [ 'Reference/Global_Objects/Array" class="type"><Array>' + '' }, + { + 'file': common.fixturesDir + '/doc_with_yaml.md', + 'html': '

Sample Markdown with YAML info' + + '#

' + + '

Foobar#

' + + ' ' + + '

Describe Foobar in more detail here.

' + + '

Deprecated thingy#' + + '

' + + '

Describe ' + + 'Deprecated thingy in more detail here.

' + + '

Something#

' + + ' ' + + '

Describe Something in more detail here. ' + + '

' + }, ]; testData.forEach(function(item) { diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index 31e260fcb02d43..ed7eb64a0e961d 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -64,6 +64,53 @@ var testData = [ 'displayName': 'Title' } ] } + }, + { + 'file': common.fixturesDir + '/doc_with_yaml.md', + 'json': { + 'source': 'foo', + 'modules': [ + { + 'textRaw': 'Sample Markdown with YAML info', + 'name': 'sample_markdown_with_yaml_info', + 'modules': [ + { + 'textRaw': 'Foobar', + 'name': 'foobar', + 'meta': { + 'added': 'v1.0.0' + }, + 'desc': '

Describe Foobar in more detail ' + + 'here.\n\n

\n', + 'type': 'module', + 'displayName': 'Foobar' + }, + { + 'textRaw': 'Deprecated thingy', + 'name': 'deprecated_thingy', + 'meta': { + 'added': 'v1.0.0', + 'deprecated': 'v2.0.0' + }, + 'desc': '

Describe Deprecated thingy in more ' + + 'detail here.\n\n

\n', + 'type': 'module', + 'displayName': 'Deprecated thingy' + }, + { + 'textRaw': 'Something', + 'name': 'something', + 'desc': '\n\n

' + + 'Describe Something in more detail here.\n

\n', + 'type': 'module', + 'displayName': 'Something' + } + ], + 'type': 'module', + 'displayName': 'Sample Markdown with YAML info' + } + ] + } } ]; diff --git a/test/fixtures/doc_with_yaml.md b/test/fixtures/doc_with_yaml.md new file mode 100644 index 00000000000000..03411d5bf7b295 --- /dev/null +++ b/test/fixtures/doc_with_yaml.md @@ -0,0 +1,21 @@ +# Sample Markdown with YAML info + +## Foobar + + +Describe `Foobar` in more detail here. + +## Deprecated thingy + + +Describe `Deprecated thingy` in more detail here. + +## Something + + +Describe `Something` in more detail here.