added tests for function readSpecFile

This commit is contained in:
Dhroov7
2019-12-09 19:23:08 +05:30
parent 5deb2c9e0f
commit 7e4eacf966
2 changed files with 21 additions and 7 deletions

View File

@@ -83,13 +83,11 @@ module.exports = {
output: convertedCollections
});
}
// eslint-disable-next-line no-else-return
else {
return cb(null, {
result: false,
reason: reasonForFail
});
}
return cb(null, {
result: false,
reason: reasonForFail
});
});
}
// eslint-disable-next-line no-else-return

View File

@@ -43,4 +43,20 @@ describe('PARSE FUNCTION TESTS', function() {
expect(result.openapi).to.equal('3.0.0');
});
describe('readSpecFile function', function() {
it('Should return the content from a remote file', function() {
let file = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification' +
'/master/examples/v3.0/api-with-examples.yaml';
parse.readSpecFile(file).then((result) => {
expect(result.startsWith('openapi: "3.0.0"')).to.equal(true);
});
});
it('Should return the content from a local file', function() {
let file = path.join(__dirname, '../data/valid_openapi/petstore.yaml');
parse.readSpecFile(file).then((result) => {
expect(result.startsWith('openapi: 3.0.0')).to.equal(true);
});
});
});
});