File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ var parser = require ( '../' ) ;
2
+ var test = require ( 'tape' ) ;
3
+ var fs = require ( 'fs' ) ;
4
+ var path = require ( 'path' ) ;
5
+
6
+ var files = {
7
+ main : path . join ( __dirname , '/files/main.js' ) ,
8
+ foo : path . join ( __dirname , '/files/foo.js' ) ,
9
+ bar : path . join ( __dirname , '/files/bar.js' )
10
+ } ;
11
+
12
+ var sources = Object . keys ( files ) . reduce ( function ( acc , file ) {
13
+ acc [ file ] = fs . readFileSync ( files [ file ] , 'utf8' ) ;
14
+ return acc ;
15
+ } , { } ) ;
16
+
17
+ test ( 'undef file' , function ( t ) {
18
+ t . plan ( 1 ) ;
19
+ var p = parser ( ) ;
20
+ p . end ( { id : files . main , entry : true } ) ;
21
+
22
+ var rows = [ ] ;
23
+ p . on ( 'data' , function ( row ) { rows . push ( row ) } ) ;
24
+ p . on ( 'end' , function ( ) {
25
+ t . same ( rows . sort ( cmp ) , [
26
+ {
27
+ id : files . main ,
28
+ source : sources . main ,
29
+ entry : true ,
30
+ deps : { './foo' : files . foo }
31
+ } ,
32
+ {
33
+ id : files . foo ,
34
+ file : files . foo ,
35
+ source : sources . foo ,
36
+ deps : { './bar' : files . bar }
37
+ } ,
38
+ {
39
+ id : files . bar ,
40
+ file : files . bar ,
41
+ source : sources . bar ,
42
+ deps : { }
43
+ }
44
+ ] . sort ( cmp ) ) ;
45
+ } ) ;
46
+ } ) ;
47
+
48
+ function cmp ( a , b ) { return a . id < b . id ? - 1 : 1 }
You can’t perform that action at this time.
0 commit comments