More test + fix decodeURIComponent call

Previously I was calling decodeURIComponent on regex match result which
was an array. This fixes that and alos adds more tests
This commit is contained in:
Mohsen Azimi
2015-01-30 16:34:08 -08:00
parent 9e8473308f
commit ae4686b0dd
3 changed files with 31 additions and 4 deletions

4
dist/index.html vendored
View File

@@ -24,9 +24,9 @@
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
var url = decodeURIComponent(window.location.search.match(/url=([^&]+)/));
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = url[1];
url = decodeURIComponent(url[1]);
} else {
url = "http://petstore.swagger.wordnik.com/v2/swagger.json";
}

View File

@@ -24,9 +24,9 @@
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
var url = decodeURIComponent(window.location.search.match(/url=([^&]+)/));
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = url[1];
url = decodeURIComponent(url[1]);
} else {
url = "http://petstore.swagger.wordnik.com/v2/swagger.json";
}

View File

@@ -66,6 +66,33 @@ describe('basics', function (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();