From 9c7092694de90808335e9e549ca8fa1db93a3da4 Mon Sep 17 00:00:00 2001
From: Dongho Yu
Date: Sun, 6 Jan 2019 19:54:38 +0900
Subject: [PATCH] Add some TOC tests
---
package.json | 10 +++--
test/fixtures/toc1.txt | 90 ++++++++++++++++++++++++++++++++++++++++++
test/index.js | 14 +++++++
3 files changed, 110 insertions(+), 4 deletions(-)
create mode 100644 test/fixtures/toc1.txt
create mode 100644 test/index.js
diff --git a/package.json b/package.json
index 66402da..a15e8aa 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "Markdown-it plugin to add Wiki style Table Of Contents",
"main": "index.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "./node_modules/mocha/bin/mocha test/*.js --reporter spec"
},
"repository": {
"type": "git",
@@ -23,7 +23,9 @@
"url": "https://github.com/n0rr7882/markdown-it-wiki-toc/issues"
},
"homepage": "https://github.com/n0rr7882/markdown-it-wiki-toc#readme",
- "dependencies": {
- "markdown-it": "^8.4.2"
+ "devDependencies": {
+ "markdown-it": "^8.4.2",
+ "markdown-it-testgen": "^0.1.4",
+ "mocha": "^5.2.0"
}
-}
+}
\ No newline at end of file
diff --git a/test/fixtures/toc1.txt b/test/fixtures/toc1.txt
new file mode 100644
index 0000000..d2ac70d
--- /dev/null
+++ b/test/fixtures/toc1.txt
@@ -0,0 +1,90 @@
+Test1
+.
+@[toc]
+.
+Table of Contents
+.
+
+Test2
+.
+@[toc]
+
+# First H1
+
+Some contents...
+
+## First H2
+
+Some contents...
+
+# Second H1
+
+## Second H2
+
+### First H3
+.
+
+1. First H1
+Some contents...
+1.1. First H2
+Some contents...
+2. Second H1
+2.1. Second H2
+
+.
+
+Test3
+.
+@[toc]
+
+First Title
+===========
+
+Some Content
+
+SubTitle
+--------
+
+Some content
+
+Second Title
+============
+
+### First H3
+.
+Table of Contents
- 1. First Title
- 2. Second Title
+1. First Title
+Some Content
+1.1. SubTitle
+Some content
+2. Second Title
+
+.
+
+Test4
+.
+@[toc]
+
+#### H4
+
+### H3
+
+## H2
+
+# H1
+
+## H2
+
+### H3
+
+#### H4
+.
+
+
+
+
+
+
+
+
+.
\ No newline at end of file
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..1bf901f
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,14 @@
+'use strict';
+
+var path = require('path');
+var generate = require('markdown-it-testgen');
+var md = require('markdown-it')({
+ html: true,
+ linkify: true,
+ typography: true
+})
+ .use(require('../'));
+
+describe('markdown-it-wiki-toc', function () {
+ generate(path.join(__dirname, 'fixtures/toc1.txt'), md);
+});