@@ -27,6 +27,9 @@ describe('Worker: apiUse', function() {
2727 var filenames = [ 'fileA' , 'fileB' , 'fileC' ] ;
2828
2929 // TODO: Add 1.000 more possible cases ;-)
30+ // the tree is build like
31+ // root
32+ // l
3033 var parsedFilesSimpleTest = [
3134 //file
3235 [
@@ -40,7 +43,6 @@ describe('Worker: apiUse', function() {
4043 test : [ 'root' ]
4144 } ,
4245 expected : 'root' ,
43- index : 2
4446 } ,
4547 {
4648 global : {
@@ -53,12 +55,126 @@ describe('Worker: apiUse', function() {
5355 local : {
5456 test : [ 'l' ]
5557 } ,
56- index : 1 ,
5758 expected : 'l'
5859 }
5960 ]
6061 ] ;
6162
63+ // the tree is build like
64+ // root
65+ // l, r
66+ // ll, rr
67+ // rrl, rrr
68+ var parsedFilesRecursiveTest = [
69+ //file
70+ [
71+ {
72+ global : { } ,
73+ local : {
74+ use : [
75+ { name : 'leaf_l' } ,
76+ { name : 'leaf_r' } ,
77+ ] ,
78+ name : 'root' ,
79+ test : [ 'root' ]
80+ } ,
81+ expected : 'root' ,
82+ }
83+ ] ,
84+ [
85+ {
86+ global : {
87+ define : {
88+ name : 'leaf_l' ,
89+ title : '' ,
90+ description : '' ,
91+ }
92+ } ,
93+ local : {
94+ test : [ 'l' ] ,
95+ use : [
96+ { name : 'leaf_ll' }
97+ ] ,
98+ } ,
99+ expected : 'l'
100+ } ,
101+ {
102+ global : {
103+ define : {
104+ name : 'leaf_rr' ,
105+ title : '' ,
106+ description : '' ,
107+ }
108+ } ,
109+ local : {
110+ test : [ 'rr' ] ,
111+ use : [
112+ { name : 'leaf_rrr' } ,
113+ { name : 'leaf_rrl' }
114+ ] ,
115+ } ,
116+ expected : 'rr'
117+ }
118+ ] ,
119+ [
120+ {
121+ global : {
122+ define : {
123+ name : 'leaf_ll' ,
124+ title : '' ,
125+ description : '' ,
126+ }
127+ } ,
128+ local : {
129+ test : [ 'll' ]
130+ } ,
131+ expected : 'll'
132+ } ,
133+ {
134+ global : {
135+ define : {
136+ name : 'leaf_r' ,
137+ title : '' ,
138+ description : '' ,
139+ }
140+ } ,
141+ local : {
142+ test : [ 'r' ] ,
143+ use : [
144+ { name : 'leaf_rr' }
145+ ] ,
146+ } ,
147+ expected : 'r'
148+ } ,
149+ {
150+ global : {
151+ define : {
152+ name : 'leaf_rrr' ,
153+ title : '' ,
154+ description : '' ,
155+ }
156+ } ,
157+ local : {
158+ test : [ 'rrr' ]
159+ } ,
160+ expected : 'rrr'
161+ } ,
162+ {
163+ global : {
164+ define : {
165+ name : 'leaf_rrl' ,
166+ title : '' ,
167+ description : '' ,
168+ }
169+ } ,
170+ local : {
171+ test : [ 'rrl' ]
172+ } ,
173+ expected : 'rrl'
174+ }
175+ ]
176+ ] ;
177+
62178 // create
63179 it ( 'case 1: simple test' , function ( done ) {
64180 var preProcess = worker . preProcess ( parsedFilesSimpleTest , filenames , packageInfos ) ;
@@ -67,6 +183,7 @@ describe('Worker: apiUse', function() {
67183 var rootBlock = parsedFilesSimpleTest [ 0 ] [ 0 ] ;
68184 rootBlock . local . name . should . eql ( 'root' ) ;
69185
186+ //check if the root block contains the expected value from every other block
70187 parsedFilesSimpleTest . forEach ( function ( parsedFile , parsedFileIndex ) {
71188 parsedFile . forEach ( function ( block ) {
72189 rootBlock . local . test . should . containEql ( block . expected ) ;
@@ -75,4 +192,22 @@ describe('Worker: apiUse', function() {
75192 done ( ) ;
76193 } ) ;
77194
195+ it ( 'case 2: recursive test' , function ( done ) {
196+ var preProcess = worker . preProcess ( parsedFilesRecursiveTest , filenames , packageInfos ) ;
197+ worker . postProcess ( parsedFilesRecursiveTest , filenames , preProcess , packageInfos ) ;
198+
199+ var rootBlock = parsedFilesRecursiveTest [ 0 ] [ 0 ] ;
200+ rootBlock . local . name . should . eql ( 'root' ) ;
201+
202+ //console.log(rootBlock);
203+
204+ //check if the root block contains the expected value from every other block
205+ parsedFilesRecursiveTest . forEach ( function ( parsedFile , parsedFileIndex ) {
206+ parsedFile . forEach ( function ( block ) {
207+ rootBlock . local . test . should . containEql ( block . expected ) ;
208+ } ) ;
209+ } ) ;
210+ done ( ) ;
211+ } ) ;
212+
78213} ) ;
0 commit comments