mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Adding tests for openapi2postman executable
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ node_modules/*
|
|||||||
.coverage/*
|
.coverage/*
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
npm-debug.log.*
|
npm-debug.log.*
|
||||||
|
tempOutput.json
|
||||||
33
test/data/invalid_openapi/multiple-components.yaml
Normal file
33
test/data/invalid_openapi/multiple-components.yaml
Normal file
@@ -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
|
||||||
34
test/unit/bin.test.js
Normal file
34
test/unit/bin.test.js
Normal file
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -4,7 +4,7 @@ var path = '../../',
|
|||||||
packageJson = require(path + '/package.json');
|
packageJson = require(path + '/package.json');
|
||||||
|
|
||||||
/* global describe, it */
|
/* global describe, it */
|
||||||
describe(packageJson.name, function() {
|
describe('Plugin ' + packageJson.name, function() {
|
||||||
var sampleInput = packageJson.com_postman_plugin.sample_input;
|
var sampleInput = packageJson.com_postman_plugin.sample_input;
|
||||||
|
|
||||||
it('should contain all com_postman_plugin attributes', function (done) {
|
it('should contain all com_postman_plugin attributes', function (done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user