@@ -7,35 +7,71 @@ describe('rules/disallow-space-after-comma', function() {
77 beforeEach ( function ( ) {
88 checker = new Checker ( ) ;
99 checker . registerDefaultRules ( ) ;
10+ checker . configure ( { disallowSpaceAfterComma : true } ) ;
1011 } ) ;
1112
12- it ( 'does not allow spaces after commas' , function ( ) {
13- checker . configure ( { disallowSpaceAfterComma : true } ) ;
13+ it ( 'does not allow spaces after commas in var delarations' , function ( ) {
14+ expect ( checker . checkString ( 'var a, b;' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
15+ } ) ;
1416
15- expect ( checker . checkString ( '[a, b]' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
17+ it ( 'does not allow tabs after commas in var delarations' , function ( ) {
18+ expect ( checker . checkString ( 'var a,\tb;' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
1619 } ) ;
1720
18- it ( 'does not allow tabs after commas' , function ( ) {
19- checker . configure ( { disallowSpaceAfterComma : true } ) ;
21+ it ( 'does allow commas with no spaces in var delarations' , function ( ) {
22+ expect ( checker . checkString ( 'var a,b,c;' ) ) . to . have . no . errors ( ) ;
23+ } ) ;
2024
21- expect ( checker . checkString ( '[a,\tb]' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
25+ it ( 'does allow commas with spaces before in var delarations' , function ( ) {
26+ expect ( checker . checkString ( 'var a ,b ,c;' ) ) . to . have . no . errors ( ) ;
2227 } ) ;
2328
24- it ( 'does allow commas with no spaces' , function ( ) {
25- checker . configure ( { disallowSpaceAfterComma : true } ) ;
29+ it ( 'does allow commas with newline character after in var delarations' , function ( ) {
30+ expect ( checker . checkString ( 'var a,\nb,\nc;' ) ) . to . have . no . errors ( ) ;
31+ } ) ;
2632
27- expect ( checker . checkString ( '[a,b,c]' ) ) . to . have . no . errors ( ) ;
33+ it ( 'does not allow spaces after commas in arrays' , function ( ) {
34+ expect ( checker . checkString ( '[a, b]' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
2835 } ) ;
2936
30- it ( 'does allow commas with spaces before' , function ( ) {
31- checker . configure ( { disallowSpaceAfterComma : true } ) ;
37+ it ( 'does not allow tabs after commas in arrays' , function ( ) {
38+ expect ( checker . checkString ( '[a,\tb]' ) ) . to . have . one . validation . error . from ( 'disallowSpaceAfterComma' ) ;
39+ } ) ;
3240
33- expect ( checker . checkString ( '[a ,b ,c]' ) ) . to . have . no . errors ( ) ;
41+ it ( 'does allow commas with no spaces in arrays' , function ( ) {
42+ expect ( checker . checkString ( '[a,b,c]' ) ) . to . have . no . errors ( ) ;
3443 } ) ;
3544
36- it ( 'does allow commas with newline character after' , function ( ) {
37- checker . configure ( { disallowSpaceAfterComma : true } ) ;
45+ it ( 'does allow commas with spaces before in arrays' , function ( ) {
46+ expect ( checker . checkString ( '[a ,b ,c]' ) ) . to . have . no . errors ( ) ;
47+ } ) ;
3848
49+ it ( 'does allow commas with newline character after in arrays' , function ( ) {
3950 expect ( checker . checkString ( '[a,\nb,\nc]' ) ) . to . have . no . errors ( ) ;
4051 } ) ;
52+
53+ it ( 'does allow sparse arrays' , function ( ) {
54+ expect ( checker . checkString ( '[a, , ,b,c]' ) ) . to . have . no . errors ( ) ;
55+ } ) ;
56+
57+ it ( 'does not allow spaces after commas in objects' , function ( ) {
58+ expect ( checker . checkString ( 'var a = {x: 1, y: 2};' ) ) . to . have . one . validation . error ( ) ;
59+ } ) ;
60+
61+ it ( 'does not allow tabs after commas in objects' , function ( ) {
62+ expect ( checker . checkString ( 'var a = {x: 1,\ty: 2};' ) ) . to . have . one . validation . error ( ) ;
63+ } ) ;
64+
65+ it ( 'does allow commas with no spaces in objects' , function ( ) {
66+ expect ( checker . checkString ( 'var a = {x: 1,y: 2};' ) ) . to . have . no . errors ( ) ;
67+ } ) ;
68+
69+ it ( 'does allow commas with spaces before in objects' , function ( ) {
70+ expect ( checker . checkString ( 'var a = {x: 1 ,y: 2};' ) ) . to . have . no . errors ( ) ;
71+ } ) ;
72+
73+ it ( 'does allow commas with newline character after in objects' , function ( ) {
74+ expect ( checker . checkString ( 'var a = {x: 1,\ny: 2,\nz: 3};' ) ) . to . have . no . errors ( ) ;
75+ } ) ;
76+
4177} ) ;
0 commit comments