|
| 1 | +describe('lib/rules/validate-jsdoc/require-newline-after-description', function () { |
| 2 | + var checker = global.checker({ |
| 3 | + additionalRules: ['lib/rules/validate-jsdoc.js'] |
| 4 | + }); |
| 5 | + |
| 6 | + describe('not configured', function() { |
| 7 | + |
| 8 | + it('should report with undefined', function() { |
| 9 | + global.expect(function() { |
| 10 | + checker.configure({requireNewlineAfterDescription: undefined}); |
| 11 | + }).to.throws(/accepted value/i); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should report with an object', function() { |
| 15 | + global.expect(function() { |
| 16 | + checker.configure({requireNewlineAfterDescription: {}}); |
| 17 | + }).to.throws(/accepted value/i); |
| 18 | + }); |
| 19 | + |
| 20 | + }); |
| 21 | + |
| 22 | + describe('with true', function() { |
| 23 | + checker.rules({requireNewlineAfterDescription: true}); |
| 24 | + |
| 25 | + checker.cases([ |
| 26 | + /* jshint ignore:start */ |
| 27 | + { |
| 28 | + it: 'should not report common cases', |
| 29 | + code: function() { |
| 30 | + function fun(p) { |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Description |
| 35 | + */ |
| 36 | + function fun(p) { |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @param p |
| 41 | + */ |
| 42 | + function fun(p) { |
| 43 | + } |
| 44 | + } |
| 45 | + }, { |
| 46 | + it: 'should report newline absence after description', |
| 47 | + code: function () { |
| 48 | + /** |
| 49 | + * Some description |
| 50 | + * @param {number} p description without hyphen |
| 51 | + */ |
| 52 | + function fun(p) { |
| 53 | + } |
| 54 | + }, |
| 55 | + errors: { |
| 56 | + line: 2, |
| 57 | + column: 19 |
| 58 | + }, |
| 59 | + }, { |
| 60 | + it: 'should not report newline after description', |
| 61 | + code: function () { |
| 62 | + /** |
| 63 | + * Some description. |
| 64 | + * Get me higher and higher! |
| 65 | + * |
| 66 | + * @param {number} p description without hyphen |
| 67 | + */ |
| 68 | + function fun(p) {} |
| 69 | + } |
| 70 | + } |
| 71 | + /* jshint ignore:end */ |
| 72 | + ]); |
| 73 | + |
| 74 | + }); |
| 75 | + |
| 76 | +}); |
0 commit comments