mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Removing duplicated tests
This commit is contained in:
@@ -2,7 +2,6 @@ const SchemaPack = require('../..').SchemaPack,
|
||||
expect = require('chai').expect,
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
SWAGGER_20_FOLDER_YAML = '../data/valid_swagger/yaml/',
|
||||
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/';
|
||||
|
||||
describe('SchemaPack instance creation', function() {
|
||||
@@ -59,97 +58,4 @@ describe('Convert method', function() {
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('Should convert a swagger document with YAML anchors', function(done) {
|
||||
const fileData = fs.readFileSync(path.join(__dirname, SWAGGER_20_FOLDER_YAML, 'yaml_anchor.yaml'), 'utf8'),
|
||||
input = {
|
||||
type: 'string',
|
||||
data: fileData
|
||||
},
|
||||
schemapack = new SchemaPack(input);
|
||||
schemapack.convert((error, result) => {
|
||||
expect(error).to.be.null;
|
||||
expect(result.result).to.equal(true);
|
||||
expect(result.output.length).to.equal(1);
|
||||
expect(result.output[0].type).to.have.equal('collection');
|
||||
expect(result.output[0].data).to.have.property('info');
|
||||
expect(result.output[0].data).to.have.property('item');
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('must read values consumes', function (done) {
|
||||
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger_aws_2.json'),
|
||||
input = {
|
||||
type: 'file',
|
||||
data: fileData
|
||||
},
|
||||
schemapack = new SchemaPack(input, { requestName: 'url' });
|
||||
|
||||
schemapack.convert((err, convertResult) => {
|
||||
expect(err).to.be.null;
|
||||
// Make sure that consumes and produces are processed
|
||||
convertResult.output.forEach(function(element) {
|
||||
expect(element.type).to.equal('collection');
|
||||
expect(JSON.stringify(element.data.item[0].request.header[0])).to
|
||||
.equal('{"key":"Content-Type","value":"application/json"}');
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert a swagger object which only have a root path.', function(done) {
|
||||
const fileData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'), 'utf8')
|
||||
),
|
||||
input = {
|
||||
type: 'json',
|
||||
data: fileData
|
||||
},
|
||||
schemapack = new SchemaPack(input, {});
|
||||
|
||||
schemapack.convert((err, result) => {
|
||||
expect(result.result).to.equal(true);
|
||||
expect(result.output.length).to.equal(1);
|
||||
expect(result.output[0].type).to.have.equal('collection');
|
||||
expect(result.output[0].data).to.have.property('info');
|
||||
expect(result.output[0].data).to.have.property('item');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should name the requests based on requestNameSource parameter, value=`URL`', function (done) {
|
||||
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'),
|
||||
input = {
|
||||
type: 'file',
|
||||
data: fileData
|
||||
},
|
||||
schemapack = new SchemaPack(input, { requestNameSource: 'URL' });
|
||||
|
||||
schemapack.convert((err, convertResult) => {
|
||||
let request = convertResult.output[0].data.item[0].request;
|
||||
|
||||
expect(err).to.be.null;
|
||||
expect(request.name).to.equal('{{baseUrl}}/');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should name the requests based on requestNameSource parameter, value=`Fallback`', function (done) {
|
||||
const fileData = path.join(__dirname, SWAGGER_20_FOLDER_JSON, 'swagger3.json'),
|
||||
input = {
|
||||
type: 'file',
|
||||
data: fileData
|
||||
},
|
||||
schemapack = new SchemaPack(input, { requestNameSource: 'Fallback' });
|
||||
|
||||
schemapack.convert((err, convertResult) => {
|
||||
let request = convertResult.output[0].data.item[0].request;
|
||||
|
||||
expect(err).to.be.null;
|
||||
expect(request.name).to.equal('List API versions');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user