mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
Fix e2e and unit tests
This commit is contained in:
parent
4aa212547f
commit
1aa9c4a3f2
|
@ -78,17 +78,17 @@ describe('Menu service', () => {
|
||||||
scroll.$scrollParent = document.querySelector('#parent');
|
scroll.$scrollParent = document.querySelector('#parent');
|
||||||
menu.activeCatIdx.should.be.equal(0);
|
menu.activeCatIdx.should.be.equal(0);
|
||||||
menu.activeMethodIdx.should.be.equal(-1);
|
menu.activeMethodIdx.should.be.equal(-1);
|
||||||
let elTop = menu.getCurrentMethodEl().getBoundingClientRect().bottom;
|
let nextElTop = menu.getRelativeCatOrItem(1).getBoundingClientRect().top;
|
||||||
|
|
||||||
scroll.$scrollParent.scrollTop = elTop + 1;
|
scroll.$scrollParent.scrollTop = nextElTop + 1;
|
||||||
|
|
||||||
//simulate scroll down
|
//simulate scroll down
|
||||||
spyOn(scroll, 'scrollY').and.returnValue(elTop + 2);
|
spyOn(scroll, 'scrollY').and.returnValue(nextElTop + 10);
|
||||||
menu.scrollUpdate(true);
|
menu.scrollUpdate(true);
|
||||||
menu.activeCatIdx.should.be.equal(1);
|
menu.activeCatIdx.should.be.equal(1);
|
||||||
|
|
||||||
scroll.scrollY.and.returnValue(elTop - 2);
|
scroll.scrollY.and.returnValue(nextElTop - 2);
|
||||||
scroll.$scrollParent.scrollTop = elTop - 1;
|
scroll.$scrollParent.scrollTop = nextElTop - 1;
|
||||||
menu.scrollUpdate(false);
|
menu.scrollUpdate(false);
|
||||||
menu.activeCatIdx.should.be.equal(0);
|
menu.activeCatIdx.should.be.equal(0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<script>
|
<script>
|
||||||
window.redocError = null;
|
window.redocError = null;
|
||||||
/* init redoc */
|
/* init redoc */
|
||||||
var url = window.location.search.substr(5) || 'http://rebilly.github.io/SwaggerTemplateRepo/swagger.json';
|
var url = window.location.search.substr(5) || 'http://rebilly.github.io/ReDoc/swagger.yaml';
|
||||||
Redoc.init(decodeURIComponent(url), {disableLazySchemas: true, suppressWarnings: true}).then(function() {}, function(err) {
|
Redoc.init(decodeURIComponent(url), {disableLazySchemas: true, suppressWarnings: true}).then(function() {}, function(err) {
|
||||||
window.redocError = err;
|
window.redocError = err;
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,13 @@ const eachNth = require('./helpers').eachNth;
|
||||||
|
|
||||||
const URL = 'index.html';
|
const URL = 'index.html';
|
||||||
|
|
||||||
|
function waitForInit() {
|
||||||
|
var EC = protractor.ExpectedConditions;
|
||||||
|
var $apiInfo = $('api-info');
|
||||||
|
var $errorMessage = $('.redoc-error')
|
||||||
|
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
|
||||||
|
}
|
||||||
|
|
||||||
function basicTests(swaggerUrl, title) {
|
function basicTests(swaggerUrl, title) {
|
||||||
describe(`Basic suite for ${title}`, () => {
|
describe(`Basic suite for ${title}`, () => {
|
||||||
let specUrl = URL;
|
let specUrl = URL;
|
||||||
|
@ -15,11 +22,8 @@ function basicTests(swaggerUrl, title) {
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
var EC = protractor.ExpectedConditions;
|
|
||||||
var $apiInfo = $('api-info');
|
|
||||||
var $errorMessage = $('.redoc-error')
|
|
||||||
browser.wait(EC.or(EC.visibilityOf($apiInfo), EC.visibilityOf($errorMessage)), 60000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -46,6 +50,7 @@ describe('Scroll sync', () => {
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,6 +76,7 @@ describe('Language tabs sync', () => {
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
browser.get(specUrl);
|
browser.get(specUrl);
|
||||||
|
waitForInit();
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,7 +106,6 @@ if (process.env.JOB === 'e2e-guru') {
|
||||||
delete apisGuruList['clarify.io']; // non-string references
|
delete apisGuruList['clarify.io']; // non-string references
|
||||||
//delete apisGuruList['pushpay.com']; // https://github.com/Rebilly/ReDoc/issues/30
|
//delete apisGuruList['pushpay.com']; // https://github.com/Rebilly/ReDoc/issues/30
|
||||||
delete apisGuruList['bbci.co.uk']; // too big
|
delete apisGuruList['bbci.co.uk']; // too big
|
||||||
delete apisGuruList['bbc.com']; // too big
|
|
||||||
|
|
||||||
// run quick version of e2e test on all builds except releases
|
// run quick version of e2e test on all builds except releases
|
||||||
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {
|
if (process.env.TRAVIS && !process.env.TRAVIS_TAG) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
---
|
---
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
info:
|
info:
|
||||||
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
|
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
title: "Swagger Petstore"
|
title: "Swagger Petstore"
|
||||||
termsOfService: "http://swagger.io/terms/"
|
termsOfService: "http://swagger.io/terms/"
|
||||||
|
@ -12,56 +11,50 @@
|
||||||
license:
|
license:
|
||||||
name: "Apache 2.0"
|
name: "Apache 2.0"
|
||||||
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
|
description: |-
|
||||||
|
# Pagination
|
||||||
|
Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in
|
||||||
|
any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next
|
||||||
|
set of data.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
...
|
||||||
|
"pagination": {
|
||||||
|
"next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
|
||||||
|
"next_max_id": "13872296"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On views where pagination is present, we also support the `count` parameter.
|
||||||
|
Simply set this to the number of items you'd like to receive. Note that the default values
|
||||||
|
should be fine for most applications - but if you decide to increase this number there is a maximum value
|
||||||
|
defined on each endpoint.
|
||||||
|
|
||||||
|
# JSONP
|
||||||
|
This is a sample server Petstore server.
|
||||||
|
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on
|
||||||
|
[irc.freenode.net, #swagger](http://swagger.io/irc/).
|
||||||
|
For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
If you're writing an AJAX application, and you'd like to wrap our response with a callback,
|
||||||
|
all you have to do is specify a callback parameter with any API call:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction
|
||||||
|
```
|
||||||
|
Would respond with:
|
||||||
|
|
||||||
|
```js
|
||||||
|
callbackFunction({
|
||||||
|
...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
> Example of markdown blockquote
|
||||||
host: "petstore.swagger.io"
|
host: "petstore.swagger.io"
|
||||||
basePath: "/v2"
|
basePath: "/v2"
|
||||||
tags:
|
tags:
|
||||||
-
|
|
||||||
name: "Pagination"
|
|
||||||
x-traitTag: true
|
|
||||||
description: |-
|
|
||||||
Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in
|
|
||||||
any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next
|
|
||||||
set of data.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
...
|
|
||||||
"pagination": {
|
|
||||||
"next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
|
|
||||||
"next_max_id": "13872296"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
On views where pagination is present, we also support the `count` parameter.
|
|
||||||
Simply set this to the number of items you'd like to receive. Note that the default values
|
|
||||||
should be fine for most applications - but if you decide to increase this number there is a maximum value
|
|
||||||
defined on each endpoint.
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
-
|
|
||||||
name: "JSONP"
|
|
||||||
x-traitTag: true
|
|
||||||
description: |-
|
|
||||||
If you're writing an AJAX application, and you'd like to wrap our response with a callback,
|
|
||||||
all you have to do is specify a callback parameter with any API call:
|
|
||||||
|
|
||||||
```
|
|
||||||
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction
|
|
||||||
```
|
|
||||||
Would respond with:
|
|
||||||
|
|
||||||
```js
|
|
||||||
callbackFunction({
|
|
||||||
...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
> Example of markdown blockquote
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
-
|
-
|
||||||
name: "pet"
|
name: "pet"
|
||||||
description: "Everything about your Pets"
|
description: "Everything about your Pets"
|
||||||
|
|
|
@ -75,9 +75,9 @@ describe('Utils', () => {
|
||||||
|
|
||||||
describe('byPointer method', () => {
|
describe('byPointer method', () => {
|
||||||
it('should return correct schema part', ()=> {
|
it('should return correct schema part', ()=> {
|
||||||
let part = specMgr.byPointer('/tags/3');
|
let part = specMgr.byPointer('/tags/0');
|
||||||
part.should.be.deepEqual(specMgr.schema.tags[3]);
|
part.should.be.deepEqual(specMgr.schema.tags[0]);
|
||||||
part.should.be.equal(specMgr.schema.tags[3]);
|
part.should.be.equal(specMgr.schema.tags[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null for incorrect pointer', ()=> {
|
it('should return null for incorrect pointer', ()=> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user