Skip to content

Commit b46e86e

Browse files
committed
chore(test): add mdast parse
1 parent 9f2fba5 commit b46e86e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"gitbook-plugin-richquotes": "0.0.5",
4949
"gitbook-summary-to-path": "^1.0.1",
5050
"jsdom": "^6.3.0",
51+
"mdast": "^2.1.0",
5152
"mocha": "^2.2.5",
5253
"node-fetch": "^1.3.2",
5354
"npm-run-all": "^1.2.8",
@@ -58,13 +59,15 @@
5859
"textlint-rule-no-mix-dearu-desumasu": "^1.1.0",
5960
"textlint-rule-no-start-duplicated-conjunction": "^1.0.3",
6061
"textlint-rule-prh": "^1.0.1",
61-
"textlint-rule-spellcheck-tech-word": "^4.0.1"
62+
"textlint-rule-spellcheck-tech-word": "^4.0.1",
63+
"unist-util-select": "^1.0.0"
6264
},
6365
"dependencies": {
6466
"esprima": "^2.5.0",
6567
"estraverse": "^4.1.0",
6668
"gulp": "^3.9.0",
6769
"gulp-util": "^3.0.6",
68-
"jquery": "^2.1.4"
70+
"jquery": "^2.1.4",
71+
"stemming-x-keywords": "^1.0.3"
6972
}
7073
}

test/keywords-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import {getFilePathListAsync} from "gitbook-summary-to-path";
44
import path from "path";
55
import fs from "fs";
6+
import mdast from "mdast";
7+
var select = require('unist-util-select');
68
const rootDir = path.join(__dirname, "..");
79
const keywordInfo = require("./keywords.json");
8-
10+
const Org = fs.readFileSync(__dirname + "/../ORGANIZATION.md","utf-8");
911
function getKeywords(matchPath) {
1012
return getFilePathListAsync(__dirname + "/../SUMMARY.md").then(fileList => {
1113
let filteredList = fileList.filter(filePath => {
@@ -32,6 +34,8 @@ function isNotContain(content, keywords) {
3234
// キーワードが書くコンテンツに含まれているかをテストする
3335
describe("keywords", function () {
3436
it("Each chapter contain the keyword", function (done) {
37+
let ast = mdast.parse(Org);
38+
let headingPrs = select(ast, "heading, heading + paragraph");
3539
let promises = Object.keys(keywordInfo).map(key => {
3640
return getKeywords(key).then(({filePath, content, keywords}) => {
3741
let unusedKeywords = isNotContain(content, keywords);

0 commit comments

Comments
 (0)