@@ -7,37 +7,78 @@ describe('rules/disallow-space-after-object-keys', function() {
77 beforeEach ( function ( ) {
88 checker = new Checker ( ) ;
99 checker . registerDefaultRules ( ) ;
10- checker . configure ( { disallowSpaceAfterObjectKeys : true } ) ;
1110 } ) ;
1211
13- it ( 'should report with space(s) after keys ', function ( ) {
14- assert ( checker . checkString ( 'var x = { a : 1, b: 2 };' ) . getErrorCount ( ) === 1 ) ;
15- assert ( checker . checkString ( 'var x = { abc : 1, b : 2 };' ) . getErrorCount ( ) === 2 ) ;
16- } ) ;
12+ describe ( 'true option ', function ( ) {
13+ beforeEach ( function ( ) {
14+ checker . configure ( { disallowSpaceAfterObjectKeys : true } ) ;
15+ } ) ;
1716
18- it ( 'should report with end of line after keys' , function ( ) {
19- assert ( checker . checkString (
20- 'var x = {' +
21- ' a\n' +
22- ' :\n' +
23- ' 2\n' +
24- '}'
25- ) . getErrorCount ( ) === 1 ) ;
26- } ) ;
17+ it ( 'should report with space(s) after keys' , function ( ) {
18+ assert ( checker . checkString ( 'var x = { a : 1, b: 2 };' ) . getErrorCount ( ) === 1 ) ;
19+ assert ( checker . checkString ( 'var x = { abc : 1, b : 2 };' ) . getErrorCount ( ) === 2 ) ;
20+ } ) ;
21+
22+ it ( 'should report with end of line after keys' , function ( ) {
23+ assert ( checker . checkString (
24+ 'var x = {' +
25+ ' a\n' +
26+ ' :\n' +
27+ ' 2\n' +
28+ '}'
29+ ) . getErrorCount ( ) === 1 ) ;
30+ } ) ;
2731
28- it ( 'should not report without space after keys' , function ( ) {
29- assert ( checker . checkString ( 'var x = { a: 1, bcd: 2 };' ) . isEmpty ( ) ) ;
32+ it ( 'should not report without space after keys' , function ( ) {
33+ assert ( checker . checkString ( 'var x = { a: 1, bcd: 2 };' ) . isEmpty ( ) ) ;
34+ } ) ;
35+
36+ it ( 'should not report shorthand object properties' , function ( ) {
37+ checker . configure ( { esnext : true } ) ;
38+ assert ( checker . checkString ( 'var x = { a, b };' ) . isEmpty ( ) ) ;
39+ assert ( checker . checkString ( 'var x = {a, b};' ) . isEmpty ( ) ) ;
40+ } ) ;
41+
42+ it ( 'should report mixed shorthand and normal object propertis' , function ( ) {
43+ checker . configure ( { esnext : true } ) ;
44+ assert . equal ( checker . checkString ( 'var x = { a : 1, b };' ) . getErrorCount ( ) , 1 ) ;
45+ } ) ;
3046 } ) ;
3147
32- it ( 'should not report shorthand object properties' , function ( ) {
33- checker . configure ( { esnext : true } ) ;
34- assert ( checker . checkString ( 'var x = { a, b };' ) . isEmpty ( ) ) ;
35- assert ( checker . checkString ( 'var x = {a, b};' ) . isEmpty ( ) ) ;
48+ describe ( 'ignoreSingleLine option' , function ( ) {
49+ beforeEach ( function ( ) {
50+ checker . configure ( { disallowSpaceAfterObjectKeys : 'ignoreSingleLine' } ) ;
51+ } ) ;
52+
53+ it ( 'should not report with an object that takes up a single line' , function ( ) {
54+ assert ( checker . checkString ( 'var x = {a : 1, bcd : 2};' ) . isEmpty ( ) ) ;
55+ } ) ;
56+
57+ it ( 'should report with an object that takes up a multi line' , function ( ) {
58+ assert ( checker . checkString (
59+ 'var x = {\n' +
60+ 'a : 1,\n' +
61+ '};'
62+ ) . getErrorCount ( ) === 1 ) ;
63+ } ) ;
3664 } ) ;
3765
38- it ( 'should report mixed shorthand and normal object propertis' , function ( ) {
39- checker . configure ( { esnext : true } ) ;
40- assert . equal ( checker . checkString ( 'var x = { a : 1, b };' ) . getErrorCount ( ) , 1 ) ;
66+ describe ( 'ignoreMultiLine option' , function ( ) {
67+ beforeEach ( function ( ) {
68+ checker . configure ( { disallowSpaceAfterObjectKeys : 'ignoreMultiLine' } ) ;
69+ } ) ;
70+
71+ it ( 'should report with an object that takes up a single line' , function ( ) {
72+ assert ( checker . checkString ( 'var x = {a : 1, bcd : 2};' ) . getErrorCount ( ) === 2 ) ;
73+ } ) ;
74+
75+ it ( 'should not report with an object that takes up a multi line' , function ( ) {
76+ assert ( checker . checkString (
77+ 'var x = {\n' +
78+ 'a : 1,\n' +
79+ '};'
80+ ) . isEmpty ( ) ) ;
81+ } ) ;
4182 } ) ;
4283
4384 it ( 'should not report es6-methods. #1013' , function ( ) {
0 commit comments