Skip to content

Commit

Permalink
fix(test): improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 3, 2019
1 parent 9079a04 commit 9343679
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/wrap-report-handler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ describe("wrapReportHandler", function () {
"rule-key": function (context) {
const { RuleError } = context;
return wrapReportHandler({
ignoreNodeTypes: Object.keys(ASTNodeTypes)
ignoreNodeTypes: Object.keys(ASTNodeTypes).concat("my-type")
}, context, report => {
return {
...(Object.keys(ASTNodeTypes).reduce((object, key) => {
object[key] = (node: AnyTxtNode) => {
report(node, new RuleError(node.type));
};
return object;
}, {} as any))
}, {} as any)),
...{
"my-type"(node) {
report(node, new RuleError(node.type));
}
}
};
});
} as TextlintRuleReporter
Expand Down Expand Up @@ -119,7 +124,7 @@ code
},
];
textlint.setupRules({
"rule-key": function (context: any) {
"rule-key": function (context) {
const { Syntax, getSource } = context;
return wrapReportHandler({
ignoreNodeTypes: [context.Syntax.Code]
Expand All @@ -136,7 +141,7 @@ code
}
}
});
}
} as TextlintRuleReporter
});
const text = "123`456`789";
return textlint.lintMarkdown(text).then((result) => {
Expand All @@ -154,7 +159,7 @@ code
const text = "> Line 1\n"
+ "> This is `code`.";
textlint.setupRules({
"rule-key": function (context: any) {
"rule-key": function (context) {
const { Syntax, RuleError } = context;
return wrapReportHandler({
ignoreNodeTypes: [context.Syntax.Code]
Expand All @@ -175,7 +180,7 @@ code
}
}
});
}
} as TextlintRuleReporter
});
return textlint.lintMarkdown(text).then((result) => {
const messages = result.messages;
Expand Down

0 comments on commit 9343679

Please sign in to comment.