Skip to content

Commit c8318c9

Browse files
Tests: Cleanup requireDictionaryWords
1 parent 301c3c8 commit c8318c9

File tree

1 file changed

+103
-102
lines changed

1 file changed

+103
-102
lines changed

test/specs/rules/require-dictionary-words.js

Lines changed: 103 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -3,114 +3,13 @@ var assert = require('assert');
33

44
describe('rules/require-dictionary-words', function() {
55
var checker;
6+
67
beforeEach(function() {
78
checker = new Checker();
89
checker.registerDefaultRules();
910
checker.configure({ plugins: ['./lib/index.js'] });
1011
});
1112

12-
describe('inline configuration', function() {
13-
beforeEach(function() {
14-
checker.configure({ requireDictionaryWords: true });
15-
});
16-
17-
it('should later allow and later disallow inline', function() {
18-
assert(checker.checkString([
19-
'asdf = 1',
20-
'// jscs:allowWords asdf, jkl',
21-
'asdf = 1',
22-
'// jscs:disallowWords asdf, jkl',
23-
'asdf = 1',
24-
].join('\n')).getErrorCount() === 2);
25-
26-
assert(checker.checkString([
27-
'asdf = 1',
28-
'jkl = 1',
29-
'// jscs:allowWords asdf, jkl',
30-
'asdf = 1',
31-
'jkl = 1',
32-
'// jscs:disallowWords asdf, jkl',
33-
'asdf = 1',
34-
'jkl = 1'
35-
].join('\n')).getErrorCount() === 4);
36-
});
37-
38-
it('should allow words inline', function() {
39-
assert(checker.checkString([
40-
'// jscs:allowWords asdf, jkl',
41-
'asdf = 1',
42-
'asdfAsdf = 1',
43-
'object.jkl = 1',
44-
'object.jklJkl = 1'
45-
].join('\n')).isEmpty());
46-
});
47-
48-
it('should allow words in identifiers inline', function() {
49-
assert(checker.checkString([
50-
'// jscs:allowWordsInIdentifiers asdf, jkl',
51-
'asdf = 1',
52-
'asdfAsdf = 1'
53-
].join('\n')).isEmpty());
54-
assert(checker.checkString([
55-
'// jscs:allowWordsInIdentifiers asdf, jkl',
56-
'object.jkl = 1',
57-
'object.jklJkl = 1'
58-
].join('\n')).getErrorCount() === 3);
59-
});
60-
61-
it('should allow words in properties inline', function() {
62-
assert(checker.checkString([
63-
'// jscs:allowWordsInProperties asdf, jkl',
64-
'object.jkl = 1',
65-
'object.jklJkl = 1'
66-
].join('\n')).isEmpty());
67-
assert(checker.checkString([
68-
'// jscs:allowWordsInProperties asdf, jkl',
69-
'asdf = 1',
70-
'asdfAsdf = 1'
71-
].join('\n')).getErrorCount() === 3);
72-
});
73-
74-
it('should allow names inline', function() {
75-
assert(checker.checkString([
76-
'// jscs:allowNames asdf, jkl',
77-
'asdf = 1',
78-
'object.jkl = 1'
79-
].join('\n')).isEmpty());
80-
assert(checker.checkString([
81-
'// jscs:allowNames asdf, jkl',
82-
'asdfAsdf = 1',
83-
'object.jklJkl = 1'
84-
].join('\n')).getErrorCount() === 4);
85-
});
86-
87-
it('should allow names as identifiers inline', function() {
88-
assert(checker.checkString([
89-
'// jscs:allowNamesAsIdentifiers asdf, jkl',
90-
'asdf = 1'
91-
].join('\n')).isEmpty());
92-
assert(checker.checkString([
93-
'// jscs:allowNamesAsIdentifiers asdf, jkl',
94-
'asdfAsdf = 1',
95-
'object.jkl = 1',
96-
'object.jklJkl = 1'
97-
].join('\n')).getErrorCount() === 5);
98-
});
99-
100-
it('should allow names as properties inline', function() {
101-
assert(checker.checkString([
102-
'// jscs:allowNamesAsProperties asdf, jkl',
103-
'object.jkl = 1'
104-
].join('\n')).isEmpty());
105-
assert(checker.checkString([
106-
'// jscs:allowNamesAsProperties asdf, jkl',
107-
'asdf = 1',
108-
'asdfAsdf = 1',
109-
'object.jklJkl = 1'
110-
].join('\n')).getErrorCount() === 5);
111-
});
112-
});
113-
11413
describe('true', function() {
11514
beforeEach(function() {
11615
checker.configure({ requireDictionaryWords: true });
@@ -359,4 +258,106 @@ describe('rules/require-dictionary-words', function() {
359258
});
360259
});
361260
});
261+
262+
describe('inline configuration', function() {
263+
beforeEach(function() {
264+
checker.configure({ requireDictionaryWords: true });
265+
});
266+
267+
it('should later allow and later disallow inline', function() {
268+
assert(checker.checkString([
269+
'asdf = 1',
270+
'// jscs:allowWords asdf, jkl',
271+
'asdf = 1',
272+
'// jscs:disallowWords asdf, jkl',
273+
'asdf = 1'
274+
].join('\n')).getErrorCount() === 2);
275+
276+
assert(checker.checkString([
277+
'asdf = 1',
278+
'jkl = 1',
279+
'// jscs:allowWords asdf, jkl',
280+
'asdf = 1',
281+
'jkl = 1',
282+
'// jscs:disallowWords asdf, jkl',
283+
'asdf = 1',
284+
'jkl = 1'
285+
].join('\n')).getErrorCount() === 4);
286+
});
287+
288+
it('should allow words inline', function() {
289+
assert(checker.checkString([
290+
'// jscs:allowWords asdf, jkl',
291+
'asdf = 1',
292+
'asdfAsdf = 1',
293+
'object.jkl = 1',
294+
'object.jklJkl = 1'
295+
].join('\n')).isEmpty());
296+
});
297+
298+
it('should allow words in identifiers inline', function() {
299+
assert(checker.checkString([
300+
'// jscs:allowWordsInIdentifiers asdf, jkl',
301+
'asdf = 1',
302+
'asdfAsdf = 1'
303+
].join('\n')).isEmpty());
304+
assert(checker.checkString([
305+
'// jscs:allowWordsInIdentifiers asdf, jkl',
306+
'object.jkl = 1',
307+
'object.jklJkl = 1'
308+
].join('\n')).getErrorCount() === 3);
309+
});
310+
311+
it('should allow words in properties inline', function() {
312+
assert(checker.checkString([
313+
'// jscs:allowWordsInProperties asdf, jkl',
314+
'object.jkl = 1',
315+
'object.jklJkl = 1'
316+
].join('\n')).isEmpty());
317+
assert(checker.checkString([
318+
'// jscs:allowWordsInProperties asdf, jkl',
319+
'asdf = 1',
320+
'asdfAsdf = 1'
321+
].join('\n')).getErrorCount() === 3);
322+
});
323+
324+
it('should allow names inline', function() {
325+
assert(checker.checkString([
326+
'// jscs:allowNames asdf, jkl',
327+
'asdf = 1',
328+
'object.jkl = 1'
329+
].join('\n')).isEmpty());
330+
assert(checker.checkString([
331+
'// jscs:allowNames asdf, jkl',
332+
'asdfAsdf = 1',
333+
'object.jklJkl = 1'
334+
].join('\n')).getErrorCount() === 4);
335+
});
336+
337+
it('should allow names as identifiers inline', function() {
338+
assert(checker.checkString([
339+
'// jscs:allowNamesAsIdentifiers asdf, jkl',
340+
'asdf = 1'
341+
].join('\n')).isEmpty());
342+
assert(checker.checkString([
343+
'// jscs:allowNamesAsIdentifiers asdf, jkl',
344+
'asdfAsdf = 1',
345+
'object.jkl = 1',
346+
'object.jklJkl = 1'
347+
].join('\n')).getErrorCount() === 5);
348+
});
349+
350+
it('should allow names as properties inline', function() {
351+
assert(checker.checkString([
352+
'// jscs:allowNamesAsProperties asdf, jkl',
353+
'object.jkl = 1'
354+
].join('\n')).isEmpty());
355+
assert(checker.checkString([
356+
'// jscs:allowNamesAsProperties asdf, jkl',
357+
'asdf = 1',
358+
'asdfAsdf = 1',
359+
'object.jklJkl = 1'
360+
].join('\n')).getErrorCount() === 5);
361+
});
362+
});
362363
});

0 commit comments

Comments
 (0)