@@ -16,6 +16,7 @@ describe('nodegen library', function () {
1616 packageSourceCode . version . should . equal ( '0.0.1' ) ;
1717 fs . statSync ( result + '/node.html' ) . size . should . be . above ( 0 ) ;
1818 fs . statSync ( result + '/node.js' ) . size . should . be . above ( 0 ) ;
19+ fs . statSync ( result + '/test/node_spec.js' ) . size . should . be . above ( 0 ) ;
1920 fs . statSync ( result + '/icons/icon.png' ) . size . should . be . above ( 0 ) ;
2021 fs . statSync ( result + '/README.md' ) . size . should . be . above ( 0 ) ;
2122 fs . statSync ( result + '/LICENSE' ) . size . should . be . above ( 0 ) ;
@@ -95,7 +96,9 @@ describe('nodegen library', function () {
9596 nodegen . function2node ( data , options ) . then ( function ( result ) {
9697 fs . statSync ( result ) . isFile ( ) . should . be . eql ( true ) ;
9798 del . sync ( result ) ;
98- del . sync ( result . replace ( / - [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + \. t g z $ / , '' ) ) ;
99+ var jsfile = result . replace ( / - [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + \. t g z $ / , '/node.js' ) ;
100+ fs . readFileSync ( jsfile ) . toString ( ) . split ( '\n' ) . length . should . be . eql ( 1 ) ;
101+ del . sync ( jsfile ) ;
99102 done ( ) ;
100103 } ) ;
101104 } ) ;
@@ -116,6 +119,7 @@ describe('nodegen library', function () {
116119 fs . statSync ( result + '/node.html' ) . size . should . be . above ( 0 ) ;
117120 fs . statSync ( result + '/node.js' ) . size . should . be . above ( 0 ) ;
118121 fs . statSync ( result + '/lib.js' ) . size . should . be . above ( 0 ) ;
122+ fs . statSync ( result + '/test/node_spec.js' ) . size . should . be . above ( 0 ) ;
119123 fs . statSync ( result + '/icons/icon.png' ) . size . should . be . above ( 0 ) ;
120124 fs . statSync ( result + '/locales/en-US/node.json' ) . size . should . be . above ( 0 ) ;
121125 fs . statSync ( result + '/locales/ja/node.json' ) . size . should . be . above ( 0 ) ;
@@ -127,7 +131,25 @@ describe('nodegen library', function () {
127131 } ) ;
128132 } ) ;
129133 } ) ;
134+ it ( 'should handle options' , function ( done ) {
135+ var options = {
136+ tgz : true ,
137+ obfuscate : true
138+ } ;
139+ var data = { dst : '.' } ;
140+ var sourcePath = 'http://petstore.swagger.io/v2/swagger.json' ;
141+ request ( sourcePath , function ( error , response , body ) {
142+ data . src = JSON . parse ( body ) ;
143+ nodegen . swagger2node ( data , options ) . then ( function ( result ) {
144+ fs . statSync ( result ) . isFile ( ) . should . be . eql ( true ) ;
145+ del . sync ( result ) ;
146+ var jsfile = result . replace ( / - [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + \. t g z $ / , '/node.js' ) ;
147+ fs . readFileSync ( jsfile ) . toString ( ) . split ( '\n' ) . length . should . be . eql ( 1 ) ;
148+ del . sync ( jsfile ) ;
149+ done ( ) ;
150+ } ) ;
151+ } ) ;
152+ } ) ;
130153 } ) ;
131-
132154} ) ;
133155
0 commit comments