@@ -172,7 +172,7 @@ describe('Converter', function() {
172
172
describe ( 'reversable - from swagger 2 raml 2 swagger' , function ( ) {
173
173
var baseDir = __dirname + '/../data/reversable/swagger' ;
174
174
var testFiles = fs . readdirSync ( baseDir ) ;
175
-
175
+
176
176
var testWithData = function ( testFile ) {
177
177
return function ( done ) {
178
178
var testFilePath = baseDir + '/' + testFile ;
@@ -261,7 +261,7 @@ describe('reversable - from raml 2 swagger 2 raml', function () {
261
261
describe ( 'from swagger to raml' , function ( ) {
262
262
var baseDir = __dirname + '/../data/swagger-import/swagger' ;
263
263
var testFiles = fs . readdirSync ( baseDir ) ;
264
-
264
+
265
265
var testWithData = function ( sourceFile , targetFile , stringCompare ) {
266
266
return function ( done ) {
267
267
var ramlVersion = _ . includes ( sourceFile , 'raml08' ) ? specConverter . Formats . RAML08 : specConverter . Formats . RAML10 ;
@@ -270,9 +270,9 @@ describe('from swagger to raml', function () {
270
270
try {
271
271
converter . convert ( 'yaml' , function ( err , covertedRAML ) {
272
272
if ( err ) return done ( err ) ;
273
-
273
+
274
274
var notExistsTarget = ! fs . existsSync ( targetFile ) ;
275
-
275
+
276
276
if ( notExistsTarget ) {
277
277
console . log ( 'Content for non existing target file ' + targetFile + '\n.' ) ;
278
278
console . log ( '********** Begin file **********\n' ) ;
@@ -298,19 +298,21 @@ describe('from swagger to raml', function () {
298
298
} ;
299
299
300
300
testFiles . forEach ( function ( testFile ) {
301
- var sourceFile = baseDir + '/' + testFile ;
302
- var targetFile = baseDir + '/../raml/' + _ . replace ( testFile , 'json' , 'yaml' ) ;
301
+ if ( ! _ . startsWith ( testFile , '.' ) ) {
302
+ var sourceFile = baseDir + '/' + testFile ;
303
+ var targetFile = baseDir + '/../raml/' + _ . replace ( testFile , 'json' , 'yaml' ) ;
303
304
304
- if ( process . env . fileToTest ) {
305
- if ( _ . endsWith ( sourceFile , process . env . fileToTest ) ) {
306
- it ( 'test: ' + testFile , testWithData ( sourceFile , targetFile , false ) ) ;
307
- }
308
- }
309
- else {
310
- it ( 'test: ' + testFile , testWithData ( sourceFile , targetFile , false ) ) ;
311
- }
305
+ if ( process . env . fileToTest ) {
306
+ if ( _ . endsWith ( sourceFile , process . env . fileToTest ) ) {
307
+ it ( 'test: ' + testFile , testWithData ( sourceFile , targetFile , false ) ) ;
308
+ }
309
+ }
310
+ else {
311
+ it ( 'test: ' + testFile , testWithData ( sourceFile , targetFile , false ) ) ;
312
+ }
313
+ }
312
314
} ) ;
313
-
315
+
314
316
if ( ! process . env . fileToTest ) {
315
317
it ( 'should convert from swagger petstore with external refs to raml 1.0' ,
316
318
testWithData ( __dirname + '/../data/petstore-separate/spec/swagger.json' , __dirname + '/../data/petstore-separate/raml10.yaml' , true ) ) ;
@@ -320,20 +322,20 @@ describe('from swagger to raml', function () {
320
322
describe ( 'from raml to swagger' , function ( ) {
321
323
var baseDir = __dirname + '/../data/raml-import/raml' ;
322
324
var testFiles = fs . readdirSync ( baseDir ) ;
323
-
325
+
324
326
var myFsResolver = {
325
327
content : function ( filePath ) { } ,
326
328
contentAsync : function ( filePath ) {
327
329
return new Promise ( function ( resolve , reject ) {
328
330
try {
329
331
var p = path . parse ( filePath ) ;
330
-
332
+
331
333
if ( p . dir . indexOf ( 'types' ) > 0 ) {
332
334
var baseDir = p . dir . replace ( 'types' , '../../types/' ) ;
333
335
var fileName = p . base === 'Person.xyz' ? 'Person.json' : p . base ;
334
-
336
+
335
337
resolve ( fs . readFileSync ( baseDir + fileName , 'UTF8' ) ) ;
336
-
338
+
337
339
} else {
338
340
resolve ( fs . readFileSync ( filePath , 'UTF8' ) ) ;
339
341
}
@@ -344,11 +346,11 @@ describe('from raml to swagger', function () {
344
346
} ) ;
345
347
}
346
348
} ;
347
-
349
+
348
350
var myOptions = {
349
351
fsResolver : myFsResolver
350
352
} ;
351
-
353
+
352
354
var testWithData = function ( testFile ) {
353
355
return function ( done ) {
354
356
var testFilePath = baseDir + '/' + testFile ;
@@ -359,7 +361,7 @@ describe('from raml to swagger', function () {
359
361
converter . convert ( 'json' , function ( err , resultSwagger ) {
360
362
if ( err ) return done ( err ) ;
361
363
var targetFile = baseDir + '/../swagger/' + _ . replace ( testFile , 'yaml' , 'json' ) ;
362
-
364
+
363
365
var notExistsTarget = ! fs . existsSync ( targetFile ) ;
364
366
if ( notExistsTarget ) {
365
367
console . log ( 'Content for non existing target file ' + targetFile + '\n.' ) ;
@@ -380,13 +382,14 @@ describe('from raml to swagger', function () {
380
382
} ;
381
383
382
384
testFiles . forEach ( function ( testFile ) {
383
- if ( process . env . fileToTest ) {
384
- if ( _ . endsWith ( testFile , process . env . fileToTest ) ) {
385
- it ( 'test: ' + testFile , testWithData ( testFile ) ) ;
386
- }
387
- }
388
- else {
389
- it ( 'test: ' + testFile , testWithData ( testFile ) ) ;
390
- }
385
+ if ( ! _ . startsWith ( testFile , '.' ) ) {
386
+ if ( process . env . fileToTest ) {
387
+ if ( _ . endsWith ( testFile , process . env . fileToTest ) ) {
388
+ it ( 'test: ' + testFile , testWithData ( testFile ) ) ;
389
+ }
390
+ } else {
391
+ it ( 'test: ' + testFile , testWithData ( testFile ) ) ;
392
+ }
393
+ }
391
394
} ) ;
392
395
} ) ;
0 commit comments