Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 933b4d9

Browse files
committed
disallowSpacesInside*Brackets: 100% code coverage
1 parent 01ff89c commit 933b4d9

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

test/rules/disallow-spaces-inside-array-brackets.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ describe('rules/disallow-spaces-inside-array-brackets', function() {
99
checker.registerDefaultRules();
1010
});
1111

12+
describe('invalid options', function() {
13+
it('should throw when given an number', function() {
14+
assert.throws(function() {
15+
checker.configure({ disallowSpacesInsideArrayBrackets: 2 });
16+
});
17+
});
18+
});
19+
1220
describe('true value', function() {
1321
beforeEach(function() {
1422
checker.configure({ disallowSpacesInsideArrayBrackets: true });
@@ -142,6 +150,15 @@ describe('rules/disallow-spaces-inside-array-brackets', function() {
142150
});
143151

144152
describe('exceptions', function() {
153+
it('should act like "true" when allExcept is false', function() {
154+
checker.configure({
155+
disallowSpacesInsideArrayBrackets: {
156+
allExcept: false
157+
}
158+
});
159+
assert(checker.checkString('var x = [ 1];').getErrorCount() === 1);
160+
});
161+
145162
it('should not report missing space for parentheses', function() {
146163
checker.configure({
147164
disallowSpacesInsideArrayBrackets: {

test/rules/disallow-spaces-inside-brackets.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ describe('rules/disallow-spaces-inside-brackets', function() {
99
checker.registerDefaultRules();
1010
});
1111

12+
describe('invalid options', function() {
13+
it('should throw when given an number', function() {
14+
assert.throws(function() {
15+
checker.configure({ disallowSpacesInsideBrackets: 2 });
16+
});
17+
});
18+
});
19+
1220
describe('true value', function() {
1321
beforeEach(function() {
1422
checker.configure({ disallowSpacesInsideBrackets: true });
@@ -67,6 +75,15 @@ describe('rules/disallow-spaces-inside-brackets', function() {
6775
});
6876

6977
describe('exceptions', function() {
78+
it('should act like "true" when allExcept is false', function() {
79+
checker.configure({
80+
disallowSpacesInsideBrackets: {
81+
allExcept: false
82+
}
83+
});
84+
assert(checker.checkString('var x = [ 1];').getErrorCount() === 1);
85+
});
86+
7087
it('should not report missing space for parentheses', function() {
7188
checker.configure({
7289
disallowSpacesInsideBrackets: {

test/rules/disallow-spaces-inside-object-brackets.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ describe('rules/disallow-spaces-inside-object-brackets', function() {
88
checker.registerDefaultRules();
99
});
1010

11+
describe('invalid options', function() {
12+
it('should throw when given an number', function() {
13+
assert.throws(function() {
14+
checker.configure({ disallowSpacesInsideObjectBrackets: 2 });
15+
});
16+
});
17+
});
18+
1119
describe('true value', function() {
1220
beforeEach(function() {
1321
checker.configure({ disallowSpacesInsideObjectBrackets: true });
@@ -87,6 +95,15 @@ describe('rules/disallow-spaces-inside-object-brackets', function() {
8795
});
8896

8997
describe('exceptions', function() {
98+
it('should act like "true" when allExcept is false', function() {
99+
checker.configure({
100+
disallowSpacesInsideObjectBrackets: {
101+
allExcept: false
102+
}
103+
});
104+
assert(checker.checkString('var x = { a: 1};').getErrorCount() === 1);
105+
});
106+
90107
it('should report for function', function() {
91108
checker.configure({
92109
disallowSpacesInsideObjectBrackets: {

0 commit comments

Comments
 (0)