-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for openapi2postman executable
- Loading branch information
1 parent
b018d9e
commit 799f91f
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ node_modules/* | |
.coverage/* | ||
npm-debug.log | ||
npm-debug.log.* | ||
tempOutput.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: 'multi-component-failure' | ||
description: 'multi-component-failure' | ||
version: '0.1' | ||
|
||
# Basic authentication | ||
components: | ||
securitySchemes: | ||
BasicAuth: | ||
type: http | ||
scheme: basic | ||
|
||
# Describe your paths here | ||
paths: | ||
/v1: | ||
get: | ||
summary: Sample summary | ||
description: Sample description | ||
operationId: sampleOperation | ||
responses: | ||
default: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
components: | ||
schemas: | ||
Error: | ||
type: object | ||
properties: | ||
status: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var expect = require('chai').expect, | ||
fs = require('fs'), | ||
exec = require('child_process').exec, | ||
collection; | ||
|
||
describe('openapi2postmanv2 ', function() { | ||
it('should print to console', function(done) { | ||
exec('./bin/openapi2postmanv2.js -s test/data/valid_openapi/petstore.json', function(err, stdout) { | ||
expect(err).to.be.null; | ||
expect(stdout).to.include('Swagger Petstore'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should print to file', function(done) { | ||
exec('./bin/openapi2postmanv2.js -s test/data/valid_openapi/petstore.json -o tempOutput.json', function(err) { | ||
expect(err).to.be.null; | ||
fs.readFile('tempOutput.json', 'utf8', (err, data) => { | ||
collection = JSON.parse(data); | ||
expect(collection.info.name).to.equal('Swagger Petstore'); | ||
expect(collection.item.length).to.equal(1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show appropriate messages for invalid input', function (done) { | ||
exec('./bin/openapi2postmanv2.js -s test/data/invalid_openapi/multiple-components.yaml', function(err, stdout) { | ||
expect(err).to.be.null; | ||
expect(stdout).to.include('duplicated mapping key'); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters