|
1 | | -describe('rules/validate-jsdoc', function () { |
| 1 | +describe('rules/validate-jsdoc', function() { |
2 | 2 | var checker = global.checker({ |
3 | 3 | additionalRules: ['lib/rules/validate-jsdoc.js'] |
4 | 4 | }); |
5 | 5 |
|
6 | | - describe('check-types', function () { |
| 6 | + describe('check-types', function() { |
7 | 7 |
|
8 | 8 | checker.rules({checkTypes: true}); |
9 | 9 | checker.cases([ |
10 | 10 | /* jshint ignore:start */ |
11 | 11 | { |
12 | | - it: 'should neither throw nor report', |
13 | | - skip: 1, |
14 | | - code: function () { |
| 12 | + it: 'should report invalid typedef', |
| 13 | + errors: 1, |
| 14 | + code: function() { |
| 15 | + /** |
| 16 | + * @typedef {something/invalid} name |
| 17 | + */ |
| 18 | + } |
| 19 | + }, { |
| 20 | + it: 'should not report empty valid typedef', |
| 21 | + code: function() { |
| 22 | + /** |
| 23 | + * @typedef alphanum |
| 24 | + */ |
| 25 | + } |
| 26 | + }, { |
| 27 | + it: 'should not report valid typedef', |
| 28 | + code: function() { |
| 29 | + /** |
| 30 | + * @typedef {(string|number)} alphanum |
| 31 | + */ |
| 32 | + } |
| 33 | + |
| 34 | + }, { |
| 35 | + it: 'should report invalid property', |
| 36 | + errors: 1, |
| 37 | + code: function() { |
| 38 | + /** |
| 39 | + * @typedef alphanum |
| 40 | + * @property {something/invalid} invalid |
| 41 | + */ |
| 42 | + } |
| 43 | + }, { |
| 44 | + it: 'should not report valid properties', |
| 45 | + code: function() { |
| 46 | + /** |
| 47 | + * @typedef {object} user |
| 48 | + * @property {number} age |
| 49 | + * @property {string} name |
| 50 | + */ |
| 51 | + } |
| 52 | + }, { |
| 53 | + it: 'should report member', |
| 54 | + code: function() { |
| 55 | + function ClsName () { |
| 56 | + /** @member {invalid/type} */ |
| 57 | + this.point = {}; |
| 58 | + } |
| 59 | + } |
| 60 | + }, { |
| 61 | + it: 'should not report member', |
| 62 | + code: function() { |
| 63 | + function ClsName () { |
| 64 | + /** @member {Object} */ |
| 65 | + this.point = {}; |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + }, { |
| 70 | + it: 'should not report member', |
| 71 | + code: function() { |
| 72 | + function ClsName () { |
| 73 | + /** @member {Object} */ |
| 74 | + this.point = {}; |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + }, { |
| 79 | + it: 'should not report return', |
| 80 | + code: function() { |
15 | 81 | /** |
16 | 82 | * @return {{a: number, b: string}} |
17 | 83 | */ |
18 | 84 | function foo() { |
19 | | - return {}; |
| 85 | + } |
| 86 | + } |
| 87 | + }, { |
| 88 | + it: 'should not report empty types in params and returns', |
| 89 | + code: function() { |
| 90 | + /** |
| 91 | + * @param q |
| 92 | + * @param w |
| 93 | + * @return |
| 94 | + */ |
| 95 | + ClsName.prototype.point = function (q, w) { |
| 96 | + } |
| 97 | + } |
| 98 | + }, { |
| 99 | + it: 'should not report valid types in params and returns', |
| 100 | + code: function() { |
| 101 | + /** |
| 102 | + * @param {Object} q |
| 103 | + * @param {Number} w |
| 104 | + * @return {String} |
| 105 | + */ |
| 106 | + ClsName.prototype.point = function (q, w) { |
| 107 | + } |
| 108 | + } |
| 109 | + }, { |
| 110 | + it: 'should report invalid types in params and returns', |
| 111 | + errors: 3, |
| 112 | + code: function() { |
| 113 | + /** |
| 114 | + * @param {Obj+ect} q |
| 115 | + * @param {Num/ber} w |
| 116 | + * @return {Str~ing} |
| 117 | + */ |
| 118 | + ClsName.prototype.point = function (q, w) { |
20 | 119 | } |
21 | 120 | } |
22 | 121 | } |
|
0 commit comments