1+ require ( 'utilise' )
2+ const fs = require ( 'fs' )
3+ , t = require ( 'tap' )
4+ , spawn = require ( 'child_process' ) . spawnSync
5+ , resolve = require ( 'path' ) . resolve
6+ , base = './test-cases/dist/resources'
7+
8+ fs . existsSync ( `${ base } /index.js` ) && fs . unlinkSync ( `${ base } /index.js` )
9+ spawn ( 'sh' , [ '-c' , `./export ${ base } ` ] , { stdio : 'inherit' } )
10+
11+ const resources = require ( base )
12+
13+ t . same ( keys ( resources ) , [
14+ 'component-function.css'
15+ , 'component-function'
16+ , 'component-object'
17+ , 'foo'
18+ ]
19+ , 'total resources'
20+ )
21+
22+ t . same ( resources [ 'component-function.css' ] , {
23+ name : 'component-function.css'
24+ , body : ":host { display: 'flex' }"
25+ }
26+ , 'css'
27+ )
28+
29+ t . same ( resources [ 'foo' ] , {
30+ name : 'foo'
31+ , body : 'bar'
32+ }
33+ , 'data' )
34+
35+ t . same ( resources [ 'component-function' ] . name
36+ , 'component-function'
37+ , 'component-function: has name'
38+ )
39+
40+ t . same ( typeof resources [ 'component-function' ] . body
41+ , 'function'
42+ , 'component-function: body is function'
43+ )
44+
45+ t . same ( resources [ 'component-function' ] . headers
46+ , { needs : '[css]' }
47+ , 'component-function: set needs headers'
48+ )
49+
50+ t . same ( resources [ 'component-object' ] . name
51+ , 'component-object'
52+ , 'component-object: has name'
53+ )
54+
55+ t . same ( typeof resources [ 'component-object' ] . body
56+ , 'function'
57+ , 'component-object: body is function'
58+ )
59+
60+ t . end ( )
0 commit comments