2
2
3
3
var test = require ( 'tap' ) . test ,
4
4
parse = require ( '../../lib/parsers/javascript' ) ,
5
- hierarchy = require ( '../../lib/hierarchy' ) ,
6
- inferName = require ( '../../lib/infer/name' ) ,
7
- inferKind = require ( '../../lib/infer/kind' ) ,
8
- inferMembership = require ( '../../lib/infer/membership' ) ;
5
+ hierarchy = require ( '../../lib/hierarchy' ) ;
9
6
10
7
function toComments ( fn , filename ) {
11
8
return parse ( {
@@ -15,68 +12,53 @@ function toComments(fn, filename) {
15
12
}
16
13
17
14
function evaluate ( fn , callback ) {
18
- return hierarchy ( toComments ( fn , callback )
19
- . map ( inferName )
20
- . map ( inferKind )
21
- . map ( inferMembership ) ) ;
15
+ return hierarchy ( toComments ( fn , callback ) ) ;
22
16
}
23
17
24
18
test ( 'hierarchy' , function ( t ) {
25
19
var result = evaluate ( function ( ) {
26
20
/**
27
- * Creates a new Klass
28
- * @param {string } foo bar
21
+ * @name Class
29
22
* @class
30
23
*/
31
- function Klass ( foo ) {
32
- this . foo = foo ;
33
- }
34
24
35
25
/**
36
- * Get this Klass's foo
37
- * @returns {Number } foo
26
+ * @name getFoo
27
+ * @memberof Class
28
+ * @instance
38
29
*/
39
- Klass . prototype . getFoo = function ( ) {
40
- return this . foo ;
41
- } ;
42
30
43
31
/**
44
- * Decide whether an object is a Klass instance
45
- *
46
- * @param {Object } other bar
47
- * @returns {boolean } whether the other thing is a Klass
32
+ * @name isClass
33
+ * @memberof Class
34
+ * @static
48
35
*/
49
- Klass . isClass = function ( other ) {
50
- return other instanceof Klass ;
51
- } ;
52
36
53
37
/**
54
- * A magic number that identifies this Klass.
38
+ * @name MAGIC_NUMBER
39
+ * @memberof Class
40
+ * @static
55
41
*/
56
- Klass . MAGIC_NUMBER = 42 ;
57
42
58
43
/**
59
- * Klass event
60
- * @event event
61
- * @memberof Klass
44
+ * @name event
45
+ * @memberof Class
46
+ * @kind event
62
47
*/
63
-
64
- return Klass ;
65
48
} ) ;
66
49
67
50
t . equal ( result . length , 1 ) ;
68
51
69
52
t . equal ( result [ 0 ] . members . static . length , 2 ) ;
70
- t . deepEqual ( result [ 0 ] . members . static [ 0 ] . path , [ 'Klass ' , 'isClass' ] ) ;
53
+ t . deepEqual ( result [ 0 ] . members . static [ 0 ] . path , [ 'Class ' , 'isClass' ] ) ;
71
54
72
55
t . equal ( result [ 0 ] . members . instance . length , 1 ) ;
73
- t . deepEqual ( result [ 0 ] . members . instance [ 0 ] . path , [ 'Klass ' , 'getFoo' ] ) ;
56
+ t . deepEqual ( result [ 0 ] . members . instance [ 0 ] . path , [ 'Class ' , 'getFoo' ] ) ;
74
57
75
58
t . equal ( result [ 0 ] . events . length , 1 ) ;
76
- t . deepEqual ( result [ 0 ] . events [ 0 ] . path , [ 'Klass ' , 'event' ] ) ;
59
+ t . deepEqual ( result [ 0 ] . events [ 0 ] . path , [ 'Class ' , 'event' ] ) ;
77
60
78
61
t . end ( ) ;
79
-
80
62
} ) ;
81
63
82
64
test ( 'hierarchy - missing memberof' , function ( t ) {
@@ -86,11 +68,6 @@ test('hierarchy - missing memberof', function (t) {
86
68
* @memberof DoesNotExist
87
69
* @returns {Number } foo
88
70
*/
89
- function getFoo ( ) {
90
- return this . foo ;
91
- }
92
-
93
- getFoo ( ) ;
94
71
} ) ;
95
72
96
73
t . equal ( result . length , 1 ) ;
0 commit comments