Removing duplicated tests

This commit is contained in:
Erik Mendoza
2022-04-14 15:17:40 -05:00
parent 0f213a5168
commit 90a191dc4c

View File

@@ -2,7 +2,6 @@ const SchemaPack = require('../..').SchemaPack,
expect = require('chai').expect, expect = require('chai').expect,
fs = require('fs'), fs = require('fs'),
path = require('path'), path = require('path'),
SWAGGER_20_FOLDER_YAML = '../data/valid_swagger/yaml/',
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/'; SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/';
describe('SchemaPack instance creation', function() { describe('SchemaPack instance creation', function() {
@@ -59,97 +58,4 @@ describe('Convert method', function() {
}); });
done(); 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();
});
});
}); });