@@ -2,26 +2,60 @@ import {textlint} from "textlint"
2
2
import rule from "../src/max-ten"
3
3
import path from "path"
4
4
import assert from "power-assert"
5
+ function textIncludeTen ( count ) {
6
+ return ( new Array ( count ) ) . join ( "テスト、" ) + "です" ;
7
+ }
5
8
describe ( "max-ten" , function ( ) {
6
- beforeEach ( function ( ) {
7
- textlint . setupRules ( {
8
- "max-ten" : rule
9
- } ) ;
10
- } ) ;
11
9
afterEach ( function ( ) {
12
10
textlint . resetRules ( ) ;
13
11
} ) ;
14
- it ( "should report error" , function ( ) {
15
- var filePath = path . join ( __dirname , "/fixtures/error.md" ) ;
16
- var result = textlint . lintFile ( filePath ) ;
17
- assert ( result . filePath === filePath ) ;
18
- assert ( result . messages . length > 0 ) ;
19
- assert . equal ( result . messages [ 0 ] . ruleId , "max-ten" ) ;
12
+ context ( "when use default option" , function ( ) {
13
+ beforeEach ( function ( ) {
14
+ textlint . setupRules ( {
15
+ "max-ten" : rule
16
+ } ) ;
17
+ } ) ;
18
+ it ( "should report error" , function ( ) {
19
+ var filePath = path . join ( __dirname , "/fixtures/error.md" ) ;
20
+ var result = textlint . lintFile ( filePath ) ;
21
+ assert ( result . filePath === filePath ) ;
22
+ assert ( result . messages . length > 0 ) ;
23
+ assert . equal ( result . messages [ 0 ] . ruleId , "max-ten" ) ;
24
+ } ) ;
25
+ it ( "should not report error" , function ( ) {
26
+ var filePath = path . join ( __dirname , "/fixtures/pass.md" ) ;
27
+ var result = textlint . lintFile ( filePath ) ;
28
+ assert ( result . filePath === filePath ) ;
29
+ assert ( result . messages . length === 0 ) ;
30
+ } ) ;
20
31
} ) ;
21
- it ( "should not report error" , function ( ) {
22
- var filePath = path . join ( __dirname , "/fixtures/pass.md" ) ;
23
- var result = textlint . lintFile ( filePath ) ;
24
- assert ( result . filePath === filePath ) ;
25
- assert ( result . messages . length === 0 ) ;
32
+ context ( "Change options#maxLen" , function ( ) {
33
+ context ( "when maxLen is 5, count of `、` < 5" , function ( ) {
34
+ it ( "should not report error" , ( ) => {
35
+ textlint . setupRules ( {
36
+ "max-ten" : rule
37
+ } , {
38
+ "max-ten" : {
39
+ "max" : 5
40
+ }
41
+ } ) ;
42
+ var result = textlint . lintMarkdown ( "a、b、c、d、です。" ) ;
43
+ console . log ( result . messages ) ;
44
+ assert ( result . messages . length === 0 ) ;
45
+ } ) ;
46
+ } ) ;
47
+ context ( "when maxLen is 5, count of `、` >= 5" , function ( ) {
48
+ it ( "should report error" , ( ) => {
49
+ textlint . setupRules ( {
50
+ "max-ten" : rule
51
+ } , {
52
+ "max-ten" : {
53
+ "max" : 5
54
+ }
55
+ } ) ;
56
+ var result = textlint . lintMarkdown ( "a、b、c、d、e、です。" ) ;
57
+ assert ( result . messages . length > 0 ) ;
58
+ } ) ;
59
+ } ) ;
26
60
} ) ;
27
61
} ) ;
0 commit comments