moved tests, added 1.x, 2.0

This commit is contained in:
Tony Tam
2015-01-30 22:49:36 -08:00
parent 47e6ce540d
commit 89cb34ed1d
18 changed files with 2333 additions and 289 deletions

View File

@@ -11,19 +11,6 @@ class MainView extends Backbone.View
auth = {name: key, type: value.type, value: value}
@model.auths.push auth
if @model.info and @model.info.license and typeof @model.info.license is 'string'
name = @model.info.license
url = @model.info.licenseUrl
@model.info.license = {}
@model.info.license.name = name
@model.info.license.url = url
if !@model.info
@model.info = {}
if !@model.info.version
@model.info.version = @model.apiVersion
if @model.swaggerVersion is "2.0"
if "validatorUrl" of opts.swaggerOptions
# Validator URL specified explicitly

View File

@@ -294,7 +294,13 @@
.swagger-section .swagger-ui-wrap .message-fail {
color: #cc0000;
}
.swagger-section .swagger-ui-wrap .info_contact {
.swagger-section .swagger-ui-wrap .info_url {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_email {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_name {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_description {

View File

@@ -176,7 +176,15 @@
color: #cc0000;
}
.info_contact {
.info_url {
padding-bottom: 5px;
}
.info_email {
padding-bottom: 5px;
}
.info_name {
padding-bottom: 5px;
}

View File

@@ -3,9 +3,9 @@
<div class="info_title">{{info.title}}</div>
<div class="info_description markdown">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact.name}}<div class='info_contact'>Created by {{info.contact.name}}</div>{{/if}}
{{#if info.contact.url}}<div class='info_contact'>See more at <a href="{{info.contact.url}}">{{info.contact.url}}</a></div>{{/if}}
{{#if info.contact.email}}<div class='info_contact'><a href="mailto:{{info.contact.email}}?subject={{info.title}}">Contact the developer</a></div>{{/if}}
{{#if info.contact.name}}<div class='info_name'>Created by {{info.contact.name}}</div>{{/if}}
{{#if info.contact.url}}<div class='info_url'>See more at <a href="{{info.contact.url}}">{{info.contact.url}}</a></div>{{/if}}
{{#if info.contact.email}}<div class='info_email'><a href="mailto:{{info.contact.email}}?subject={{info.title}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.license.url}}'>{{info.license.name}}</a></div>{{/if}}
{{/if}}
</div>

View File

@@ -1,104 +0,0 @@
var webdriver = require('selenium-webdriver');
var createServer = require('http-server').createServer;
var expect = require('chai').expect;
var path = require('path')
var dist = path.join(__dirname, '..', '..', '..', 'dist');
var PORT = 8080;
console.log('started static server from', dist, 'at port', PORT);
var server = createServer({
root: dist,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
}
});
server.listen(PORT);
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.firefox()).
build();
/*
* Checks console errors and fails if there is any error
* Note: It's a good idea to run this after each operation
*/
function checkConsoleErrors () {
it('should not have any console errors', function (done) {
driver.manage().logs().get('browser').then(function(browserLogs) {
var errors = [];
browserLogs.forEach(function(log){
// 900 and above is "error" level. Console should not have any errors
if (log.level.value > 900) {
console.log('browser error message:', log.message);
errors.push(log);
}
});
expect(errors).to.be.empty;
done();
});
});
}
describe('basics', function (done) {
this.timeout(10 * 1000);
beforeEach(function () {
driver.get('http://localhost:' + PORT + '/index.html');
});
it('should have "Swagger UI" in title', function (done) {
driver.sleep(200);
driver.getTitle().then(function(title) {
expect(title).to.contain('Swagger UI');
done();
});
});
checkConsoleErrors();
});
describe('should render key elements in document', function () {
var elementQueries = [
'swagger-ui-container',
'resources_container',
'api_info',
'resource_pet',
'resource_store',
'resource_user',
'header'
];
this.timeout(10000);
elementQueries.forEach(function (id) {
it('should render element: ' + id, function (done) {
var locator = webdriver.By.id(id)
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
})
});
describe('cleanup', function () {
it('kills the static server', function () {
server.close();
});
it('quit the webdriver', function () {
driver.quit();
});
})