style: fix indent spaces from 4 to 2 in test files (#6163)

This commit is contained in:
Tim Lai
2020-06-23 09:44:24 -07:00
committed by GitHub
parent e53d450cbc
commit faae3e9d2c
18 changed files with 1122 additions and 1214 deletions

View File

@@ -1,42 +1,42 @@
describe("bug #4196: HTTP basic auth credential retention", function () { describe("bug #4196: HTTP basic auth credential retention", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4196.yaml") .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4196.yaml")
.click("button.download-url-button") .click("button.download-url-button")
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("should display the most recent auth data across modal close/opens", function (client) { it("should display the most recent auth data across modal close/opens", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000) client.waitForElementVisible(".opblock-tag-section", 10000)
.click("button.btn.authorize") // Open modal .click("button.btn.authorize") // Open modal
.waitForElementVisible("section>input", 5000) .waitForElementVisible("section>input", 5000)
.setValue("section>input", "aaa") // Set user .setValue("section>input", "aaa") // Set user
.waitForElementVisible(`section>input[type="password"]`, 5000) .waitForElementVisible(`section>input[type="password"]`, 5000)
.setValue(`section>input[type="password"]`, "aaa") // Set password .setValue(`section>input[type="password"]`, "aaa") // Set password
.click(".auth-btn-wrapper button:nth-child(1)") // Click Authorize .click(".auth-btn-wrapper button:nth-child(1)") // Click Authorize
.assert.containsText("div.wrapper:nth-child(4)>code", "aaa") .assert.containsText("div.wrapper:nth-child(4)>code", "aaa")
.click(".auth-btn-wrapper button:nth-child(2)") // Close modal .click(".auth-btn-wrapper button:nth-child(2)") // Close modal
.pause(50) .pause(50)
.click("button.btn.authorize") // Open modal .click("button.btn.authorize") // Open modal
.pause(50) .pause(50)
.click(".auth-btn-wrapper button:nth-child(1)") // Logout .click(".auth-btn-wrapper button:nth-child(1)") // Logout
.waitForElementVisible("section>input", 5000) .waitForElementVisible("section>input", 5000)
.setValue("section>input", "bbb") // Set user .setValue("section>input", "bbb") // Set user
.waitForElementVisible(`section>input[type="password"]`, 5000) .waitForElementVisible(`section>input[type="password"]`, 5000)
.setValue(`section>input[type="password"]`, "bbb") // Set password .setValue(`section>input[type="password"]`, "bbb") // Set password
.click(".auth-btn-wrapper button:nth-child(1)") // Click Authorize .click(".auth-btn-wrapper button:nth-child(1)") // Click Authorize
.pause(1000) .pause(1000)
.assert.containsText("div.wrapper:nth-child(4)>code", "bbb") .assert.containsText("div.wrapper:nth-child(4)>code", "bbb")
client.end() client.end()
}) })
}) })

View File

@@ -1,31 +1,31 @@
describe("bug #4374: OAS3 parameters should be visibly validated in Try-It-Out", function () { describe("bug #4374: OAS3 parameters should be visibly validated in Try-It-Out", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 10000) client.waitForElementVisible(".download-url-input:not([disabled])", 10000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/bugs/4374.yaml") .setValue(".download-url-input", "/test-specs/bugs/4374.yaml")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("indicates an error when a required parameter is not selected", function (client) { it("indicates an error when a required parameter is not selected", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000) client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/pet/findByStatus") .assert.containsText(".opblock-summary-path span", "/pet/findByStatus")
.click(".opblock") .click(".opblock")
.waitForElementVisible(".opblock.is-open", 5000) .waitForElementVisible(".opblock.is-open", 5000)
.click(".try-out__btn") .click(".try-out__btn")
.click(".btn.execute") .click(".btn.execute")
.pause(100) .pause(100)
.assert.cssClassPresent(".parameters-col_description select", "invalid") .assert.cssClassPresent(".parameters-col_description select", "invalid")
client.end() client.end()
}) })
}) })

View File

@@ -1,28 +1,28 @@
describe("bug #4409: operationId normalization and layout tracking", function () { describe("bug #4409: operationId normalization and layout tracking", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4409.yaml") .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4409.yaml")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("expands an operation that has a normalizable operationId", function (client) { it("expands an operation that has a normalizable operationId", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000) client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/myApi") .assert.containsText(".opblock-summary-path span", "/myApi")
.click(".opblock") .click(".opblock")
.waitForElementVisible(".opblock-body", 5000) .waitForElementVisible(".opblock-body", 5000)
.assert.cssClassPresent(".opblock", "is-open") .assert.cssClassPresent(".opblock", "is-open")
client.end() client.end()
}) })
}) })

View File

@@ -1,31 +1,28 @@
describe("bug #4445: callback-via-$ref rendering", function () { describe("bug #4409: operationId normalization and layout tracking", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4445.yaml") .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4409.yaml")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("expands an operation that has a visible callback", function (client) { it("expands an operation that has a normalizable operationId", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000) client.waitForElementVisible(".opblock-tag-section", 10000)
.click(".opblock") .assert.containsText(".opblock-summary-path span", "/myApi")
.waitForElementVisible(".opblock-body", 5000) .click(".opblock")
.click(".opblock-section-header > .tab-header > div.tab-item:nth-of-type(2)") .waitForElementVisible(".opblock-body", 5000)
.waitForElementVisible(".callbacks-container .opblock", 5000) .assert.cssClassPresent(".opblock", "is-open")
.click(".callbacks-container .opblock")
.waitForElementVisible(".callbacks-container .opblock-body", 5000)
.assert.containsText(".callbacks-container .opblock-description-wrapper:nth-of-type(2) p", "subscription payload")
client.end() client.end()
}) })
}) })

View File

@@ -1,30 +1,28 @@
describe("bug #4485: operation metadata storage when referenced via path item $ref", function () { describe("bug #4409: operationId normalization and layout tracking", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4485/main.yaml") .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4409.yaml")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("sets a consumes value for a body parameter correctly", function (client) { it("expands an operation that has a normalizable operationId", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000) client.waitForElementVisible(".opblock-tag-section", 10000)
.click(".opblock") .assert.containsText(".opblock-summary-path span", "/myApi")
.waitForElementVisible(".opblock-body", 5000) .click(".opblock")
.click("button.btn.try-out__btn") .waitForElementVisible(".opblock-body", 5000)
.click("select.content-type [value=\"application/xml\"]") .assert.cssClassPresent(".opblock", "is-open")
.pause(500)
.assert.value("select.content-type", "application/xml")
client.end() client.end()
}) })
}) })

View File

@@ -1,28 +1,28 @@
describe("bug #4536: model name consistency", function () { describe("bug #4536: model name consistency", function () {
let mainPage let mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4536.yaml") .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4536.yaml")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("consistently displays a model's name regardless of expansion state", function (client) { it("consistently displays a model's name regardless of expansion state", function (client) {
client.waitForElementVisible("span.model.model-title", 10000) client.waitForElementVisible("span.model.model-title", 10000)
.assert.containsText("span.model.model-title", "TitleName") .assert.containsText("span.model.model-title", "TitleName")
.click("span.model.model-title") .click("span.model.model-title")
.pause(500) .pause(500)
.assert.containsText("span.model-title__text", "TitleName") .assert.containsText("span.model-title__text", "TitleName")
client.end() client.end()
}) })
}) })

View File

@@ -1,47 +1,78 @@
describe("render informationContainer", function () { describe("Render Model Wrapper", function () {
let mainPage let modelWrapper, mainPage
let informationContainer
beforeEach(function (client, done) {
mainPage = client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button")
.pause(1000)
informationContainer = mainPage.section.informationContainer beforeEach(function (client, done) {
mainPage = client
done() .url("localhost:3230")
}) .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button")
.pause(1000)
it("renders section", function (client) { modelWrapper = mainPage.section.modelWrapper
mainPage.expect.section("@informationContainer").to.be.visible.before(5000)
client.end() done()
}) })
afterEach(function (client, done) {
done()
})
it("Render model wrapper", function (client) {
mainPage.expect.section("@modelWrapper").to.be.visible.before(5000)
it("renders content", function (client) { client.end()
informationContainer.waitForElementVisible("@title", 5000) })
.assert.containsText("@title", "Swagger Petstore")
.assert.containsText("@version", "1.0.0") it("Render model wrapper collapse", function (client) {
.assert.containsText("@baseUrl", "[ Base URL: localhost:3204/ ]") modelWrapper.waitForElementVisible("@modelContainer", 5000)
.assert.attributeEquals("@mainUrl", "href", "http://localhost:3230/test-specs/petstore.json") .click("@modelCollapse")
.assert.containsText("@mainUrlContent", "http://localhost:3230/test-specs/petstore.json") .assert.cssClassNotPresent("@modelContainer", "is-open")
.assert.containsText("@description", "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.")
.assert.attributeEquals("@swaggerUrl", "href", "http://swagger.io/") client.end()
.assert.attributeEquals("@swaggerircUrl", "href", "http://swagger.io/irc/") })
.assert.attributeEquals("@termsLink", "href", "http://swagger.io/terms/")
.assert.containsText("@termsLink", "Terms of service") it("Testing order model", function (client) {
.assert.attributeEquals("@contactDevLink", "href", "mailto:apiteam@swagger.io") modelWrapper.waitForElementVisible("@orderModel")
.assert.containsText("@contactDevLink", "Contact the developer") .click("@orderModelCallapse")
.assert.attributeEquals("@contactDevLink", "href", "mailto:apiteam@swagger.io") .assert.cssClassNotPresent("@orderModelCallapse", "callapsed")
.assert.containsText("@contactDevLink", "Contact the developer")
.assert.attributeEquals("@aboutSwaggerLink", "href", "http://swagger.io/") client.end()
.assert.containsText("@aboutSwaggerLink", "Find out more about Swagger") })
client.end() it("Testing category model", function (client) {
}) modelWrapper.waitForElementVisible("@categoryModel")
.click("@categoryModelCallapse")
.assert.cssClassNotPresent("@categoryModelCallapse", "callapsed")
client.end()
})
it("Testing user model", function (client) {
modelWrapper.waitForElementVisible("@userModel")
.click("@userModelCallapse")
.assert.cssClassNotPresent("@userModelCallapse", "callapsed")
client.end()
})
it("Testing tag model", function (client) {
modelWrapper.waitForElementVisible("@tagModel")
.click("@tagModelCallapse")
.assert.cssClassNotPresent("@tagModelCallapse", "callapsed")
client.end()
})
it("Testing pet model", function (client) {
modelWrapper.waitForElementVisible("@petModel")
.click("@petModelCallapse")
.assert.cssClassNotPresent("@petModelCallapse", "callapsed")
client.end()
})
it("Testing apiResponse model", function (client) {
modelWrapper.waitForElementVisible("@apiResponseModel")
.click("@apiResponseModelCallapse")
.assert.cssClassNotPresent("@apiResponseModelCallapse", "callapsed")
client.end()
})
}) })

View File

@@ -1,78 +1,78 @@
describe("Render Model Wrapper", function () { describe("Render Model Wrapper", function () {
let modelWrapper, mainPage let modelWrapper, mainPage
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json") .setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
modelWrapper = mainPage.section.modelWrapper modelWrapper = mainPage.section.modelWrapper
done() done()
}) })
afterEach(function (client, done){ afterEach(function (client, done) {
done() done()
}) })
it("Render model wrapper", function(client){ it("Render model wrapper", function (client) {
mainPage.expect.section("@modelWrapper").to.be.visible.before(5000) mainPage.expect.section("@modelWrapper").to.be.visible.before(5000)
client.end() client.end()
}) })
it("Render model wrapper collapse", function(client){ it("Render model wrapper collapse", function (client) {
modelWrapper.waitForElementVisible("@modelContainer", 5000) modelWrapper.waitForElementVisible("@modelContainer", 5000)
.click("@modelCollapse") .click("@modelCollapse")
.assert.cssClassNotPresent("@modelContainer", "is-open") .assert.cssClassNotPresent("@modelContainer", "is-open")
client.end() client.end()
}) })
it("Testing order model", function(client){ it("Testing order model", function (client) {
modelWrapper.waitForElementVisible("@orderModel") modelWrapper.waitForElementVisible("@orderModel")
.click("@orderModelCallapse") .click("@orderModelCallapse")
.assert.cssClassNotPresent("@orderModelCallapse", "callapsed") .assert.cssClassNotPresent("@orderModelCallapse", "callapsed")
client.end() client.end()
}) })
it("Testing category model", function(client){ it("Testing category model", function (client) {
modelWrapper.waitForElementVisible("@categoryModel") modelWrapper.waitForElementVisible("@categoryModel")
.click("@categoryModelCallapse") .click("@categoryModelCallapse")
.assert.cssClassNotPresent("@categoryModelCallapse", "callapsed") .assert.cssClassNotPresent("@categoryModelCallapse", "callapsed")
client.end() client.end()
}) })
it("Testing user model", function(client){ it("Testing user model", function (client) {
modelWrapper.waitForElementVisible("@userModel") modelWrapper.waitForElementVisible("@userModel")
.click("@userModelCallapse") .click("@userModelCallapse")
.assert.cssClassNotPresent("@userModelCallapse", "callapsed") .assert.cssClassNotPresent("@userModelCallapse", "callapsed")
client.end() client.end()
}) })
it("Testing tag model", function(client){ it("Testing tag model", function (client) {
modelWrapper.waitForElementVisible("@tagModel") modelWrapper.waitForElementVisible("@tagModel")
.click("@tagModelCallapse") .click("@tagModelCallapse")
.assert.cssClassNotPresent("@tagModelCallapse", "callapsed") .assert.cssClassNotPresent("@tagModelCallapse", "callapsed")
client.end() client.end()
}) })
it("Testing pet model", function(client){ it("Testing pet model", function (client) {
modelWrapper.waitForElementVisible("@petModel") modelWrapper.waitForElementVisible("@petModel")
.click("@petModelCallapse") .click("@petModelCallapse")
.assert.cssClassNotPresent("@petModelCallapse", "callapsed") .assert.cssClassNotPresent("@petModelCallapse", "callapsed")
client.end() client.end()
}) })
it("Testing apiResponse model", function(client){ it("Testing apiResponse model", function (client) {
modelWrapper.waitForElementVisible("@apiResponseModel") modelWrapper.waitForElementVisible("@apiResponseModel")
.click("@apiResponseModelCallapse") .click("@apiResponseModelCallapse")
.assert.cssClassNotPresent("@apiResponseModelCallapse", "callapsed") .assert.cssClassNotPresent("@apiResponseModelCallapse", "callapsed")
client.end() client.end()
}) })
}) })

View File

@@ -1,215 +1,112 @@
describe("render pet api container", function () { describe("render store api container", function () {
let mainPage let mainPage
let apiWrapper let apiWrapper
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json") .setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
apiWrapper = mainPage.section.apiWrapper apiWrapper = mainPage.section.apiWrapper
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("render section", function (client) { it("test rendered store container", function (client) {
mainPage.expect.section("@apiWrapper").to.be.visible.before(10000) apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000)
client.end() .expect.element("@storeAPIWrapper").to.be.visible
})
it("test rendered pet container", function (client) {
apiWrapper.waitForElementVisible("@petAPIWrapper", 5000)
.expect.element("@petAPIWrapper").to.be.visible
client.end() client.end()
}) })
it("collapse pet wrapper", function (client) { it("callapse store wrapper", function (client) {
apiWrapper.waitForElementVisible("@petAPIWrapper", 5000) apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000)
.click("@petAPIWrapperBar") .click("@storeAPIWrapperBar")
.assert.cssClassNotPresent("@petAPIWrapper", "is-open") .assert.cssClassNotPresent("@storeAPIWrapper", "is-open")
client.end() client.end()
}) })
it("render post /pet api container", function (client) { it("render get /store/inventory api container", function (client) {
apiWrapper.waitForElementVisible("@petOperationPostContainer", 10000) apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000)
.assert.containsText("@petOperationPostTitle", "/pet") .assert.containsText("@storeOperationGetTitle", "/store/inventory")
.click("@petOperationPostCollpase") .click("@storeOperationGetCollpase")
.waitForElementVisible("@petOperationPostCollapseContainer", 5000) .waitForElementVisible("@storeOperationGetCollapseContainer", 5000)
.click("@petOperationPostTryBtn") .click("@storeOperationGetTryBtn")
.waitForElementVisible("@petOperationPostTryText", 1000) .waitForElementVisible("@storeOperationGetExecuteBtn", 1000)
.waitForElementVisible("@petOperationPostExecuteBtn", 1000) .click("@storeOperationGetTryBtn")
.click("@petOperationPostTryBtn") .assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel")
.assert.cssClassNotPresent("@petOperationPostTryBtn", "cancel")
client.end() client.end()
}) })
it("Testing post /pet api Mock data", function (client) { it("Testing get /store/inventory api Mock data ", function (client) {
apiWrapper.waitForElementVisible("@petOperationPostContainer", 5000) apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000)
.click("@petOperationPostCollpase") .assert.containsText("@storeOperationGetTitle", "/store/inventory")
.waitForElementVisible("@petOperationPostCollapseContainer", 5000) .click("@storeOperationGetCollpase")
.click("@petOperationPostTryBtn") .waitForElementVisible("@storeOperationGetCollapseContainer", 3000)
.waitForElementVisible("@petOperationPostExecuteBtn", 1000) .click("@storeOperationGetTryBtn")
.click("@petOperationPostExecuteBtn") .waitForElementVisible("@storeOperationGetExecuteBtn", 1000)
.waitForElementVisible("@petOperationPostMockCategoryID", 2000) .click("@storeOperationGetExecuteBtn")
.assert.containsText("@petOperationPostMockCategoryID", "0") .waitForElementVisible("@storeOperationResponseProps1")
.assert.containsText("@petOperationPostMockCategoryName", "\"string\"") .assert.containsText("@storeOperationResponseProps1", "0")
.assert.containsText("@petOperationPostMockName", "\"doggie\"") .assert.containsText("@storeOperationResponseProps2", "0")
.assert.containsText("@petOperationPostTagID", "0") .assert.containsText("@storeOperationResponseProps3", "0")
.assert.containsText("@petOperationPostTagName", "\"string\"") .click("@storeOperationGetTryBtn")
.assert.containsText("@petOperationPostStatus", "\"available\"") .assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel")
.click("@petOperationPostTryBtn")
.assert.cssClassNotPresent("@petOperationPostTryBtn", "cancel")
client.end() client.end()
}) })
it("Testing post /pet api model values", function (client) { it("render post /store/order api container", function (client) {
apiWrapper.waitForElementVisible("@petOperationPostContainer", 5000) apiWrapper.waitForElementVisible("@storeOperationPostContainer")
.click("@petOperationPostCollpase") .assert.containsText("@storeOperationPostTitle", "/store/order")
.waitForElementVisible("@petOperationPostCollapseContainer", 5000) .click("@storeOperationPostCollpase")
.click("a.tablinks[data-name=model]") .waitForElementVisible("@storeOperationPostCollapseContainer", 3000)
.assert.containsText("span.model-title > .model-title__text", `Pet`) .click("@storeOperationPostTryBtn")
.waitForElementVisible("@storeOperationPostExecuteBtn", 1000)
.click("@storeOperationPostTryBtn")
.assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel")
client.end() client.end()
}) })
it("render put /pet api container", function (client) { it("Testing post /store/order api Mock Data", function (client) {
apiWrapper.waitForElementVisible("@petOperationPutContainer", 5000) apiWrapper.waitForElementVisible("@storeOperationPostContainer")
.assert.containsText("@petOperationPutTitle", "/pet") .assert.containsText("@storeOperationPostTitle", "/store/order")
.click("@petOperationPutCollpase") .click("@storeOperationPostCollpase")
.waitForElementVisible("@petOperationPutCollapseContainer", 3000) .waitForElementVisible("@storeOperationPostCollapseContainer", 3000)
.click("@petOperationPutTryBtn") .click("@storeOperationPostTryBtn")
.waitForElementVisible("@petOperationPutTryText", 1000) .waitForElementVisible("@storeOperationPostExecuteBtn", 1000)
.waitForElementVisible("@petOperationPutExecuteBtn", 1000) .click("@storeOperationPostExecuteBtn")
.click("@petOperationPutTryBtn") .waitForElementVisible("@storeOperationPostResponseId")
.assert.cssClassNotPresent("@petOperationPutTryBtn", "cancel") .assert.containsText("@storeOperationPostResponseId", "0")
.assert.containsText("@storeOperationPostResponsePetId", "0")
.assert.containsText("@storeOperationPostResponseQuantity", "0")
.assert.containsText("@storeOperationPostResponseStatus", "placed")
.assert.containsText("@storeOperationPostResponseComplete", "false")
.click("@storeOperationPostTryBtn")
.assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel")
client.end() client.end()
}) })
it("render delete /store/order/{orderId} api container", function (client) {
apiWrapper.waitForElementVisible("@storeOperationDeleteContainer")
.assert.containsText("@storeOperationDeleteTitle", "/store/order/{orderId}")
.click("@storeOperationDeleteCollpase")
.waitForElementVisible("@storeOperationDeleteCollapseContainer", 3000)
.click("@storeOperationDeleteTryBtn")
.waitForElementVisible("@storeOperationDeleteExecuteBtn", 1000)
.click("@storeOperationDeleteExecuteBtn")
.waitForElementVisible("@storeOperationGetResponseHeaders", "content-type: application/xml")
.click("@storeOperationDeleteTryBtn")
.assert.cssClassNotPresent("@storeOperationDeleteTryBtn", "cancel")
it("Testing put /pet api Mock data", function (client) { client.end()
apiWrapper.waitForElementVisible("@petOperationPutContainer", 5000) })
.click("@petOperationPutCollpase")
.waitForElementVisible("@petOperationPutCollapseContainer", 3000)
.click("@petOperationPutTryBtn")
.waitForElementVisible("@petOperationPutExecuteBtn", 1000)
.click("@petOperationPutExecuteBtn")
.waitForElementVisible("@petOperationPutMockCategoryID")
.assert.containsText("@petOperationPutMockCategoryID", "0")
.assert.containsText("@petOperationPutMockCategoryName", "\"string\"")
.assert.containsText("@petOperationPutMockName", "\"doggie\"")
.assert.containsText("@petOperationPutTagID", "0")
.assert.containsText("@petOperationPutTagName", "\"string\"")
.assert.containsText("@petOperationPutStatus", "\"available\"")
.click("@petOperationPutTryBtn")
.assert.cssClassNotPresent("@petOperationPutTryBtn", "Cancel")
client.end()
})
it("render get by tag /pet api container", function (client) {
apiWrapper.waitForElementVisible("@petOperationGetByTagContainer", 5000)
.assert.containsText("@petOperationGetByTagTitle", "/pet/findByTags")
.click("@petOperationGetByTagCollpase")
.waitForElementVisible("@petOperationGetByTagCollapseContainer", 3000)
.click("@petOperationGetByTagTryBtn")
.waitForElementVisible("@petOperationGetByTagTryAdded", 1000)
.waitForElementVisible("@petOperationGetByTagExecuteBtn", 1000)
.click("@petOperationGetByTagTryBtn")
.assert.cssClassNotPresent("@petOperationGetByTagTryBtn", "cancel")
client.end()
})
it("Testing get by tag /pet api Mock data", function (client) {
apiWrapper.waitForElementVisible("@petOperationGetByTagContainer", 5000)
.click("@petOperationGetByTagCollpase")
.waitForElementVisible("@petOperationGetByTagCollapseContainer", 3000)
.click("@petOperationGetByTagTryBtn")
.waitForElementVisible("@petOperationGetByTagExecuteBtn", 1000)
.click("@petOperationGetByTagExecuteBtn")
.waitForElementVisible("@petOperationGetByTagMockCategoryID")
.assert.containsText("@petOperationGetByTagMockCategoryID", "0")
.assert.containsText("@petOperationGetByTagMockCategoryName", "\"string\"")
.assert.containsText("@petOperationGetByTagMockName", "\"doggie\"")
.assert.containsText("@petOperationGetByTagTagID", "0")
.assert.containsText("@petOperationGetByTagTagName", "\"string\"")
.assert.containsText("@petOperationGetByTagStatus", "\"available\"")
.click("@petOperationGetByTagTryBtn")
.assert.cssClassNotPresent("@petOperationGetByTagTryBtn", "cancel")
client.end()
})
it("render get by ID /pet/{petId} api container", function (client) {
apiWrapper.waitForElementVisible("@petOperationGetByIdContainer", 5000)
.assert.containsText("@petOperationGetByIdTitle", "/pet/{petId}")
.click("@petOperationGetByIdCollpase")
.waitForElementVisible("@petOperationGetByIdCollapseContainer", 3000)
.click("@petOperationGetByIdTryBtn")
.waitForElementVisible("@petOperationGetByTagExecuteBtn", 1000)
.click("@petOperationGetByTagTryBtn")
.assert.cssClassNotPresent("@petOperationGetByTagTryBtn", "cancel")
client.end()
})
it("render get by ID /pet/{petId} api Mock data", function (client) {
apiWrapper.waitForElementVisible("@petOperationGetByIdContainer", 5000)
.assert.containsText("@petOperationGetByIdTitle", "/pet/{petId}")
.click("@petOperationGetByIdCollpase")
.waitForElementVisible("@petOperationGetByIdCollapseContainer", 3000)
.click("@petOperationGetByIdTryBtn")
.waitForElementVisible("@petOperationGetByTagExecuteBtn", 1000)
.setValue("@petOperationGetByIdParameter", "abc")
.click("@petOperationGetByIdExecuteBtn")
.waitForElementVisible("@petOperationGetByIdResultsBox")
.assert.containsText("@petOperationGetByIdParameter", "abc")
.assert.cssClassPresent("@petOperationGetByIdParameter", "invalid")
.assert.attributeEquals("@petOperationGetByIdParameter", "title", "Value must be an integer")
.click("@petOperationGetByTagTryBtn")
.assert.cssClassNotPresent("@petOperationGetByTagTryBtn", "cancel")
client.end()
})
it("render delete /pet api container", function (client) {
apiWrapper.waitForElementVisible("@petOperationDeleteContainer")
.assert.containsText("@petOperationDeleteTitle", "/pet/{petId}")
.click("@petOperationDeleteCollpase")
.waitForElementVisible("@petOperationDeleteCollapseContainer", 3000)
.click("@petOperationDeleteTryBtn")
.waitForElementVisible("@petOperationDeleteExecuteBtn", 1000)
.click("@petOperationDeleteTryBtn")
.assert.cssClassNotPresent("@petOperationDeleteTryBtn", "cancel")
client.end()
})
it("Testing delete /pet api Mock data", function (client) {
apiWrapper.waitForElementVisible("@petOperationDeleteContainer", 3000)
.click("@petOperationDeleteCollpase")
.waitForElementVisible("@petOperationDeleteCollapseContainer", 3000)
.click("@petOperationDeleteTryBtn")
.waitForElementVisible("@petOperationDeleteExecuteBtn", 1000)
.click("@petOperationDeleteExecuteBtn")
.waitForElementVisible("@petOperationDeleteMockCategoryID")
.assert.containsText("@petOperationDeleteMockCategoryID", "0")
.assert.containsText("@petOperationDeleteMockCategoryName", "\"string\"")
.assert.containsText("@petOperationDeleteMockName", "\"doggie\"")
.assert.containsText("@petOperationDeleteTagID", "0")
.assert.containsText("@petOperationDeleteTagName", "\"string\"")
.assert.containsText("@petOperationDeleteStatus", "\"available\"")
.click("@petOperationDeleteTryBtn")
.assert.cssClassNotPresent("@petOperationDeleteTryBtn", "cancel")
client.end()
})
}) })

View File

@@ -1,112 +1,112 @@
describe("render store api container", function(){ describe("render store api container", function () {
let mainPage let mainPage
let apiWrapper let apiWrapper
beforeEach( function(client, done){ beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json") .setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
apiWrapper = mainPage.section.apiWrapper apiWrapper = mainPage.section.apiWrapper
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("test rendered store container", function(client){ it("test rendered store container", function (client) {
apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000) apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000)
.expect.element("@storeAPIWrapper").to.be.visible .expect.element("@storeAPIWrapper").to.be.visible
client.end() client.end()
}) })
it("callapse store wrapper", function(client){ it("callapse store wrapper", function (client) {
apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000) apiWrapper.waitForElementVisible("@storeAPIWrapper", 5000)
.click("@storeAPIWrapperBar") .click("@storeAPIWrapperBar")
.assert.cssClassNotPresent("@storeAPIWrapper", "is-open") .assert.cssClassNotPresent("@storeAPIWrapper", "is-open")
client.end() client.end()
}) })
it("render get /store/inventory api container", function (client) { it("render get /store/inventory api container", function (client) {
apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000) apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000)
.assert.containsText("@storeOperationGetTitle", "/store/inventory") .assert.containsText("@storeOperationGetTitle", "/store/inventory")
.click("@storeOperationGetCollpase") .click("@storeOperationGetCollpase")
.waitForElementVisible("@storeOperationGetCollapseContainer", 5000) .waitForElementVisible("@storeOperationGetCollapseContainer", 5000)
.click("@storeOperationGetTryBtn") .click("@storeOperationGetTryBtn")
.waitForElementVisible("@storeOperationGetExecuteBtn", 1000) .waitForElementVisible("@storeOperationGetExecuteBtn", 1000)
.click("@storeOperationGetTryBtn") .click("@storeOperationGetTryBtn")
.assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel") .assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel")
client.end()
})
it("Testing get /store/inventory api Mock data ", function (client) { client.end()
apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000) })
.assert.containsText("@storeOperationGetTitle", "/store/inventory")
.click("@storeOperationGetCollpase")
.waitForElementVisible("@storeOperationGetCollapseContainer", 3000)
.click("@storeOperationGetTryBtn")
.waitForElementVisible("@storeOperationGetExecuteBtn", 1000)
.click("@storeOperationGetExecuteBtn")
.waitForElementVisible("@storeOperationResponseProps1")
.assert.containsText("@storeOperationResponseProps1", "0")
.assert.containsText("@storeOperationResponseProps2", "0")
.assert.containsText("@storeOperationResponseProps3", "0")
.click("@storeOperationGetTryBtn")
.assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel")
client.end()
})
it("render post /store/order api container", function (client) { it("Testing get /store/inventory api Mock data ", function (client) {
apiWrapper.waitForElementVisible("@storeOperationPostContainer") apiWrapper.waitForElementVisible("@storeOperationGetContainer", 5000)
.assert.containsText("@storeOperationPostTitle", "/store/order") .assert.containsText("@storeOperationGetTitle", "/store/inventory")
.click("@storeOperationPostCollpase") .click("@storeOperationGetCollpase")
.waitForElementVisible("@storeOperationPostCollapseContainer", 3000) .waitForElementVisible("@storeOperationGetCollapseContainer", 3000)
.click("@storeOperationPostTryBtn") .click("@storeOperationGetTryBtn")
.waitForElementVisible("@storeOperationPostExecuteBtn", 1000) .waitForElementVisible("@storeOperationGetExecuteBtn", 1000)
.click("@storeOperationPostTryBtn") .click("@storeOperationGetExecuteBtn")
.assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel") .waitForElementVisible("@storeOperationResponseProps1")
.assert.containsText("@storeOperationResponseProps1", "0")
client.end() .assert.containsText("@storeOperationResponseProps2", "0")
}) .assert.containsText("@storeOperationResponseProps3", "0")
.click("@storeOperationGetTryBtn")
.assert.cssClassNotPresent("@storeOperationGetTryBtn", "cancel")
it("Testing post /store/order api Mock Data", function (client) { client.end()
apiWrapper.waitForElementVisible("@storeOperationPostContainer") })
.assert.containsText("@storeOperationPostTitle", "/store/order")
.click("@storeOperationPostCollpase") it("render post /store/order api container", function (client) {
.waitForElementVisible("@storeOperationPostCollapseContainer", 3000) apiWrapper.waitForElementVisible("@storeOperationPostContainer")
.click("@storeOperationPostTryBtn") .assert.containsText("@storeOperationPostTitle", "/store/order")
.waitForElementVisible("@storeOperationPostExecuteBtn", 1000) .click("@storeOperationPostCollpase")
.click("@storeOperationPostExecuteBtn") .waitForElementVisible("@storeOperationPostCollapseContainer", 3000)
.waitForElementVisible("@storeOperationPostResponseId") .click("@storeOperationPostTryBtn")
.assert.containsText("@storeOperationPostResponseId", "0") .waitForElementVisible("@storeOperationPostExecuteBtn", 1000)
.assert.containsText("@storeOperationPostResponsePetId", "0") .click("@storeOperationPostTryBtn")
.assert.containsText("@storeOperationPostResponseQuantity", "0") .assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel")
.assert.containsText("@storeOperationPostResponseStatus", "placed")
.assert.containsText("@storeOperationPostResponseComplete", "false") client.end()
.click("@storeOperationPostTryBtn") })
.assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel")
it("Testing post /store/order api Mock Data", function (client) {
client.end() apiWrapper.waitForElementVisible("@storeOperationPostContainer")
}) .assert.containsText("@storeOperationPostTitle", "/store/order")
it("render delete /store/order/{orderId} api container", function (client) { .click("@storeOperationPostCollpase")
apiWrapper.waitForElementVisible("@storeOperationDeleteContainer") .waitForElementVisible("@storeOperationPostCollapseContainer", 3000)
.assert.containsText("@storeOperationDeleteTitle", "/store/order/{orderId}") .click("@storeOperationPostTryBtn")
.click("@storeOperationDeleteCollpase") .waitForElementVisible("@storeOperationPostExecuteBtn", 1000)
.waitForElementVisible("@storeOperationDeleteCollapseContainer", 3000) .click("@storeOperationPostExecuteBtn")
.click("@storeOperationDeleteTryBtn") .waitForElementVisible("@storeOperationPostResponseId")
.waitForElementVisible("@storeOperationDeleteExecuteBtn", 1000) .assert.containsText("@storeOperationPostResponseId", "0")
.click("@storeOperationDeleteExecuteBtn") .assert.containsText("@storeOperationPostResponsePetId", "0")
.waitForElementVisible("@storeOperationGetResponseHeaders", "content-type: application/xml") .assert.containsText("@storeOperationPostResponseQuantity", "0")
.click("@storeOperationDeleteTryBtn") .assert.containsText("@storeOperationPostResponseStatus", "placed")
.assert.cssClassNotPresent("@storeOperationDeleteTryBtn", "cancel") .assert.containsText("@storeOperationPostResponseComplete", "false")
.click("@storeOperationPostTryBtn")
client.end() .assert.cssClassNotPresent("@storeOperationPostTryBtn", "cancel")
})
client.end()
})
it("render delete /store/order/{orderId} api container", function (client) {
apiWrapper.waitForElementVisible("@storeOperationDeleteContainer")
.assert.containsText("@storeOperationDeleteTitle", "/store/order/{orderId}")
.click("@storeOperationDeleteCollpase")
.waitForElementVisible("@storeOperationDeleteCollapseContainer", 3000)
.click("@storeOperationDeleteTryBtn")
.waitForElementVisible("@storeOperationDeleteExecuteBtn", 1000)
.click("@storeOperationDeleteExecuteBtn")
.waitForElementVisible("@storeOperationGetResponseHeaders", "content-type: application/xml")
.click("@storeOperationDeleteTryBtn")
.assert.cssClassNotPresent("@storeOperationDeleteTryBtn", "cancel")
client.end()
})
}) })

View File

@@ -1,93 +1,78 @@
describe("render user api container", function(){ describe("Render Model Wrapper", function () {
let mainPage let modelWrapper, mainPage
let apiWrapper
beforeEach( function(client, done){
mainPage = client
.url("localhost:3230")
.page.main()
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) beforeEach(function (client, done) {
.clearValue(".download-url-input") mainPage = client
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json") .url("localhost:3230")
.click("button.download-url-button") .page.main()
.pause(1000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button")
.pause(1000)
apiWrapper = mainPage.section.apiWrapper modelWrapper = mainPage.section.modelWrapper
done() done()
}) })
afterEach(function (client, done) { afterEach(function (client, done) {
done() done()
}) })
it("test rendered user container", function(client){ it("Render model wrapper", function (client) {
apiWrapper.waitForElementVisible("@userAPIWrapper", 5000) mainPage.expect.section("@modelWrapper").to.be.visible.before(5000)
.expect.element("@userAPIWrapper").to.be.visible
client.end() client.end()
}) })
it("callapse user wrapper", function(client){
apiWrapper.waitForElementVisible("@userAPIWrapper", 5000)
.click("@userAPIWrapperBar")
.assert.cssClassNotPresent("@userAPIWrapper", "is-open")
client.end() it("Render model wrapper collapse", function (client) {
}) modelWrapper.waitForElementVisible("@modelContainer", 5000)
it("render put /user/{username} api container", function (client) { .click("@modelCollapse")
apiWrapper.waitForElementVisible("@userOperationPutContainer", 5000) .assert.cssClassNotPresent("@modelContainer", "is-open")
.assert.containsText("@userOperationPutTitle", "/user/{username}")
.click("@userOperationPutCollpase") client.end()
.waitForElementVisible("@userOperationPutCollapseContainer", 3000) })
.click("@userOperationPutTryBtn")
.waitForElementVisible("@userOperationPutExecuteBtn", 1000) it("Testing order model", function (client) {
.click("@userOperationPutTryBtn") modelWrapper.waitForElementVisible("@orderModel")
.assert.cssClassNotPresent("@userOperationPutTryBtn", "cancel") .click("@orderModelCallapse")
.assert.cssClassNotPresent("@orderModelCallapse", "callapsed")
client.end()
}) client.end()
it("Test put /user/{username} api Mock data", function (client) { })
apiWrapper.waitForElementVisible("@userOperationPutContainer", 5000)
.assert.containsText("@userOperationPutTitle", "/user/{username}") it("Testing category model", function (client) {
.click("@userOperationPutCollpase") modelWrapper.waitForElementVisible("@categoryModel")
.waitForElementVisible("@userOperationPutCollapseContainer", 3000) .click("@categoryModelCallapse")
.click("@userOperationPutTryBtn") .assert.cssClassNotPresent("@categoryModelCallapse", "callapsed")
.waitForElementVisible("@userOperationPutParameter")
.setValue("@userOperationPutParameter", "123") client.end()
.waitForElementVisible("@userOperationPutExecuteBtn", 1000) })
.click("userOperationPutExecuteBtn") it("Testing user model", function (client) {
.waitForElementVisible("@userOperationPutResponseHeader") modelWrapper.waitForElementVisible("@userModel")
.assert.containsText("@userOperationPutResponseHeader", "content-type: application/xml") .click("@userModelCallapse")
.click("@userOperationPutTryBtn") .assert.cssClassNotPresent("@userModelCallapse", "callapsed")
.assert.cssClassNotPresent("@userOperationPutTryBtn", "cancel")
client.end()
client.end() })
}) it("Testing tag model", function (client) {
it("render delete /user/{username} api container", function (client) { modelWrapper.waitForElementVisible("@tagModel")
apiWrapper.waitForElementVisible("@userOperationDeleteContainer", 5000) .click("@tagModelCallapse")
.assert.containsText("@userOperationDeleteTitle", "/user/{username}") .assert.cssClassNotPresent("@tagModelCallapse", "callapsed")
.click("@userOperationDeleteCollpase")
.waitForElementVisible("@userOperationDeleteCollapseContainer", 3000) client.end()
.click("@userOperationDeleteTryBtn") })
.waitForElementVisible("@userOperationDeleteExecuteBtn", 1000) it("Testing pet model", function (client) {
.click("@userOperationDeleteTryBtn") modelWrapper.waitForElementVisible("@petModel")
.assert.cssClassNotPresent("@userOperationDeleteTryBtn", "cancel") .click("@petModelCallapse")
.assert.cssClassNotPresent("@petModelCallapse", "callapsed")
client.end()
}) client.end()
it("Test delete /user/{username} api Mock data", function (client) { })
apiWrapper.waitForElementVisible("@userOperationDeleteContainer", 5000) it("Testing apiResponse model", function (client) {
.assert.containsText("@userOperationDeleteTitle", "/user/{username}") modelWrapper.waitForElementVisible("@apiResponseModel")
.click("@userOperationDeleteCollpase") .click("@apiResponseModelCallapse")
.waitForElementVisible("@userOperationDeleteCollapseContainer", 3000) .assert.cssClassNotPresent("@apiResponseModelCallapse", "callapsed")
.click("@userOperationDeleteTryBtn")
.waitForElementVisible("@userOperationDeleteParameter") client.end()
.setValue("@userOperationDeleteParameter", "123") })
.waitForElementVisible("@userOperationDeleteExecuteBtn", 1000)
.click("userOperationDeleteExecuteBtn")
.waitForElementVisible("@userOperationDeleteResponseHeader")
.assert.containsText("@userOperationDeleteResponseHeader", "content-type: application/xml")
.click("@userOperationDeleteTryBtn")
.assert.cssClassNotPresent("@userOperationDeleteTryBtn", "cancel")
client.end()
})
}) })

View File

@@ -1,61 +1,61 @@
describe("Render scheme", function () { describe("Render scheme", function () {
let mainPage let mainPage
let schemeContainer let schemeContainer
beforeEach(function (client, done) { beforeEach(function (client, done) {
mainPage = client mainPage = client
.url("localhost:3230") .url("localhost:3230")
.page.main() .page.main()
schemeContainer = mainPage.section.schemeContainer schemeContainer = mainPage.section.schemeContainer
client.waitForElementVisible(".download-url-input:not([disabled])", 5000) client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input") .clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json") .setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button") .click("button.download-url-button")
.pause(1000) .pause(1000)
done() done()
}) })
it("render section", function (client) { it("render section", function (client) {
mainPage.expect.section("@schemeContainer").to.be.visible.before(5000) mainPage.expect.section("@schemeContainer").to.be.visible.before(5000)
client.end() client.end()
}) })
it("render scheme option", function (client) { it("render scheme option", function (client) {
schemeContainer.waitForElementVisible("@httpOption", 5000) schemeContainer.waitForElementVisible("@httpOption", 5000)
.expect.element("@httpOption").to.be.selected .expect.element("@httpOption").to.be.selected
client.end() client.end()
}) })
it("render authorized button", function (client) { it("render authorized button", function (client) {
schemeContainer.waitForElementVisible("@btnAuthorize", 5000) schemeContainer.waitForElementVisible("@btnAuthorize", 5000)
.expect.element("@btnAuthorize").to.be.visible .expect.element("@btnAuthorize").to.be.visible
client.end() client.end()
}) })
it("render click event", function(client) { it("render click event", function (client) {
schemeContainer.waitForElementVisible("@btnAuthorize", 5000) schemeContainer.waitForElementVisible("@btnAuthorize", 5000)
.click("@btnAuthorize") .click("@btnAuthorize")
.assert.visible("@authorizationModal") .assert.visible("@authorizationModal")
.assert.containsText("@appName", "Application: your-app-name") .assert.containsText("@appName", "Application: your-app-name")
.assert.containsText("@authorizationUrl", "http://petstore.swagger.io/oauth/dialog") .assert.containsText("@authorizationUrl", "http://petstore.swagger.io/oauth/dialog")
.assert.containsText("@flow", "implicit") .assert.containsText("@flow", "implicit")
.assert.value("@inputClientID", "your-client-id") .assert.value("@inputClientID", "your-client-id")
schemeContainer.expect.element("@readPetsScope").to.be.selected schemeContainer.expect.element("@readPetsScope").to.be.selected
schemeContainer.expect.element("@writePetsScope").to.not.be.selected schemeContainer.expect.element("@writePetsScope").to.not.be.selected
schemeContainer.click("@selectAllScopes") schemeContainer.click("@selectAllScopes")
schemeContainer.expect.element("@readPetsScope").to.be.selected schemeContainer.expect.element("@readPetsScope").to.be.selected
schemeContainer.expect.element("@writePetsScope").to.be.selected schemeContainer.expect.element("@writePetsScope").to.be.selected
schemeContainer.click("@selectNoneScopes") schemeContainer.click("@selectNoneScopes")
schemeContainer.expect.element("@readPetsScope").to.not.be.selected schemeContainer.expect.element("@readPetsScope").to.not.be.selected
schemeContainer.expect.element("@writePetsScope").to.not.be.selected schemeContainer.expect.element("@writePetsScope").to.not.be.selected
client.end() client.end()
}) })
}) })

View File

@@ -1,51 +1,51 @@
describe("initial render", function () { describe("initial render", function () {
let mainPage let mainPage
describe("for topbar", function () { describe("for topbar", function () {
let topbar let topbar
before(function (client, done) { before(function (client, done) {
done() done()
})
after(function (client, done) {
client.end(function () {
done()
})
})
afterEach(function (client, done) {
done()
})
beforeEach(function (client, done) {
mainPage = client
.url("localhost:3230")
.page.main()
topbar = mainPage.section.topbar
client.waitForElementVisible(".download-url-input:not([disabled])", 10000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button")
.pause(1000)
done()
})
it("renders section", function (client) {
mainPage.expect.section("@topbar").to.be.visible
client.end()
})
it("renders input box", function (client) {
topbar.expect.element("@inputBox").to.be.visible
client.end()
})
it("renders explore button", function (client) {
topbar.expect.element("@btnExplore").to.be.visible
client.end()
})
}) })
after(function (client, done) {
client.end(function () {
done()
})
})
afterEach(function (client, done) {
done()
})
beforeEach(function (client, done) {
mainPage = client
.url("localhost:3230")
.page.main()
topbar = mainPage.section.topbar
client.waitForElementVisible(".download-url-input:not([disabled])", 10000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "http://localhost:3230/test-specs/petstore.json")
.click("button.download-url-button")
.pause(1000)
done()
})
it("renders section", function (client) {
mainPage.expect.section("@topbar").to.be.visible
client.end()
})
it("renders input box", function (client) {
topbar.expect.element("@inputBox").to.be.visible
client.end()
})
it("renders explore button", function (client) {
topbar.expect.element("@btnExplore").to.be.visible
client.end()
})
})
}) })

View File

@@ -5,108 +5,108 @@ import { render } from "enzyme"
import Markdown from "components/providers/markdown" import Markdown from "components/providers/markdown"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx" import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx"
describe("Markdown component", function() { describe("Markdown component", function () {
describe("Swagger 2.0", function() { describe("Swagger 2.0", function () {
it("allows elements with class, style and data-* attribs", function() { it("allows elements with class, style and data-* attribs", function () {
const getConfigs = () => ({ useUnsafeMarkdown: true }) const getConfigs = () => ({ useUnsafeMarkdown: true })
const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>` const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>`
const el = render(<Markdown source={str} getConfigs={getConfigs} />) const el = render(<Markdown source={str} getConfigs={getConfigs} />)
expect(el.html()).toEqual(`<div class="markdown"><p><span data-attr="value" style="border-width: 1px" class="method">ONE</span></p>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><p><span data-attr="value" style="border-width: 1px" class="method">ONE</span></p>\n</div>`)
}) })
it("strips class, style and data-* attribs from elements", function() { it("strips class, style and data-* attribs from elements", function () {
const getConfigs = () => ({ useUnsafeMarkdown: false }) const getConfigs = () => ({ useUnsafeMarkdown: false })
const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>` const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>`
const el = render(<Markdown source={str} getConfigs={getConfigs} />) const el = render(<Markdown source={str} getConfigs={getConfigs} />)
expect(el.html()).toEqual(`<div class="markdown"><p><span>ONE</span></p>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><p><span>ONE</span></p>\n</div>`)
}) })
it("allows td elements with colspan attrib", function() { it("allows td elements with colspan attrib", function () {
const str = `<table><tr><td>ABC</td></tr></table>` const str = `<table><tr><td>ABC</td></tr></table>`
const el = render(<Markdown source={str} />) const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><table><tbody><tr><td>ABC</td></tr></tbody></table></div>`) expect(el.html()).toEqual(`<div class="markdown"><table><tbody><tr><td>ABC</td></tr></tbody></table></div>`)
}) })
it("allows image elements", function() { it("allows image elements", function () {
const str = `![Image alt text](http://image.source "Image title")` const str = `![Image alt text](http://image.source "Image title")`
const el = render(<Markdown source={str} />) const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><p><img title="Image title" alt="Image alt text" src="http://image.source"></p>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><p><img title="Image title" alt="Image alt text" src="http://image.source"></p>\n</div>`)
}) })
it("allows image elements with https scheme", function() { it("allows image elements with https scheme", function () {
const str = `![Image alt text](https://image.source "Image title")` const str = `![Image alt text](https://image.source "Image title")`
const el = render(<Markdown source={str} />) const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><p><img title="Image title" alt="Image alt text" src="https://image.source"></p>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><p><img title="Image title" alt="Image alt text" src="https://image.source"></p>\n</div>`)
}) })
it("allows image elements with data scheme", function() { it("allows image elements with data scheme", function () {
const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">` const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">`
const el = render(<Markdown source={str} />) const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><p>` + str + `</p>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><p>` + str + `</p>\n</div>`)
}) })
it("allows heading elements", function() { it("allows heading elements", function () {
const str = ` const str = `
# h1 # h1
## h2 ## h2
### h3 ### h3
#### h4 #### h4
##### h5 ##### h5
###### h6` ###### h6`
const el = render(<Markdown source={str} />) const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6>\n</div>`) expect(el.html()).toEqual(`<div class="markdown"><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6>\n</div>`)
})
it("allows links", function() {
const str = `[Link](https://example.com/)`
const el = render(<Markdown source={str} />)
expect(el.html()).toEqual(`<div class="markdown"><p><a rel="noopener noreferrer" target="_blank" href="https://example.com/">Link</a></p>\n</div>`)
})
}) })
describe("OAS 3", function() { it("allows links", function () {
it("allows elements with class, style and data-* attribs", function() { const str = `[Link](https://example.com/)`
const getConfigs = () => ({ useUnsafeMarkdown: true }) const el = render(<Markdown source={str} />)
const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>` expect(el.html()).toEqual(`<div class="markdown"><p><a rel="noopener noreferrer" target="_blank" href="https://example.com/">Link</a></p>\n</div>`)
const el = render(<OAS3Markdown source={str} getConfigs={getConfigs} />) })
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><span data-attr="value" style="border-width: 1px" class="method">ONE</span></p></div>`) })
})
it("strips class, style and data-* attribs from elements", function() { describe("OAS 3", function () {
const getConfigs = () => ({ useUnsafeMarkdown: false }) it("allows elements with class, style and data-* attribs", function () {
const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>` const getConfigs = () => ({ useUnsafeMarkdown: true })
const el = render(<OAS3Markdown source={str} getConfigs={getConfigs} />) const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>`
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><span>ONE</span></p></div>`) const el = render(<OAS3Markdown source={str} getConfigs={getConfigs} />)
}) expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><span data-attr="value" style="border-width: 1px" class="method">ONE</span></p></div>`)
})
it("allows image elements", function() { it("strips class, style and data-* attribs from elements", function () {
const str = `![Image alt text](http://image.source "Image title")` const getConfigs = () => ({ useUnsafeMarkdown: false })
const el = render(<OAS3Markdown source={str} />) const str = `<span class="method" style="border-width: 1px" data-attr="value">ONE</span>`
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><img title="Image title" alt="Image alt text" src="http://image.source"></p></div>`) const el = render(<OAS3Markdown source={str} getConfigs={getConfigs} />)
}) expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><span>ONE</span></p></div>`)
})
it("allows image elements with https scheme", function() { it("allows image elements", function () {
const str = `![Image alt text](https://image.source "Image title")` const str = `![Image alt text](http://image.source "Image title")`
const el = render(<OAS3Markdown source={str} />) const el = render(<OAS3Markdown source={str} />)
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><img title="Image title" alt="Image alt text" src="https://image.source"></p></div>`) expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><img title="Image title" alt="Image alt text" src="http://image.source"></p></div>`)
}) })
it("allows image elements with data scheme", function() { it("allows image elements with https scheme", function () {
const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">` const str = `![Image alt text](https://image.source "Image title")`
const el = render(<OAS3Markdown source={str} />) const el = render(<OAS3Markdown source={str} />)
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p>` + str + `</p></div>`) expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><img title="Image title" alt="Image alt text" src="https://image.source"></p></div>`)
}) })
it("allows heading elements", function() { it("allows image elements with data scheme", function () {
const str = ` const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">`
const el = render(<OAS3Markdown source={str} />)
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p>` + str + `</p></div>`)
})
it("allows heading elements", function () {
const str = `
# h1 # h1
## h2 ## h2
### h3 ### h3
#### h4 #### h4
##### h5 ##### h5
###### h6` ###### h6`
const el = render(<OAS3Markdown source={str} />) const el = render(<OAS3Markdown source={str} />)
expect(el.html()).toEqual(`<div class="renderedMarkdown"><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6></div>`) expect(el.html()).toEqual(`<div class="renderedMarkdown"><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6></div>`)
})
}) })
})
}) })

View File

@@ -5,48 +5,48 @@ import { shallow } from "enzyme"
import { fromJS } from "immutable" import { fromJS } from "immutable"
import PrimitiveModel from "components/primitive-model" import PrimitiveModel from "components/primitive-model"
describe("<PrimitiveModel/>", function() { describe("<PrimitiveModel/>", function () {
describe("Model name", function() { describe("Model name", function () {
const dummyComponent = () => null const dummyComponent = () => null
const components = { const components = {
Markdown: dummyComponent, Markdown: dummyComponent,
EnumModel: dummyComponent EnumModel: dummyComponent
} }
const props = { const props = {
getComponent: c => components[c], getComponent: c => components[c],
getConfigs: () => ({ getConfigs: () => ({
showExtensions: false showExtensions: false
}), }),
name: "Name from props", name: "Name from props",
depth: 1, depth: 1,
schema: fromJS({ schema: fromJS({
type: "string", type: "string",
title: "Custom model title" title: "Custom model title"
}) })
} }
it("renders the schema's title", function() { it("renders the schema's title", function () {
// When // When
const wrapper = shallow(<PrimitiveModel {...props}/>) const wrapper = shallow(<PrimitiveModel {...props} />)
const modelTitleEl = wrapper.find("span.model-title") const modelTitleEl = wrapper.find("span.model-title")
expect(modelTitleEl.length).toEqual(1) expect(modelTitleEl.length).toEqual(1)
// Then
expect( modelTitleEl.text() ).toEqual( "Custom model title" )
})
it("falls back to the passed-in `name` prop for the title", function() {
// When
props.schema = fromJS({
type: "string"
})
const wrapper = shallow(<PrimitiveModel {...props}/>)
const modelTitleEl = wrapper.find("span.model-title")
expect(modelTitleEl.length).toEqual(1)
// Then
expect( modelTitleEl.text() ).toEqual( "Name from props" )
})
// Then
expect(modelTitleEl.text()).toEqual("Custom model title")
}) })
} )
it("falls back to the passed-in `name` prop for the title", function () {
// When
props.schema = fromJS({
type: "string"
})
const wrapper = shallow(<PrimitiveModel {...props} />)
const modelTitleEl = wrapper.find("span.model-title")
expect(modelTitleEl.length).toEqual(1)
// Then
expect(modelTitleEl.text()).toEqual("Name from props")
})
})
})

View File

@@ -3,41 +3,41 @@ import expect from "expect"
import { shallow } from "enzyme" import { shallow } from "enzyme"
import ResponseBody from "components/response-body" import ResponseBody from "components/response-body"
describe("<ResponseBody />", function() { describe("<ResponseBody />", function () {
const highlightCodeComponent = () => null const highlightCodeComponent = () => null
const components = { const components = {
highlightCode: highlightCodeComponent highlightCode: highlightCodeComponent
} }
const props = { const props = {
getComponent: c => components[c], getComponent: c => components[c],
} }
it("renders ResponseBody as 'application/json'", function() { it("renders ResponseBody as 'application/json'", function () {
props.contentType = "application/json" props.contentType = "application/json"
props.content = "{\"key\": \"a test value\"}" props.content = "{\"key\": \"a test value\"}"
const wrapper = shallow(<ResponseBody {...props}/>) const wrapper = shallow(<ResponseBody {...props} />)
expect(wrapper.find("highlightCodeComponent").length).toEqual(1) expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
}) })
it("renders ResponseBody as 'text/html'", function() { it("renders ResponseBody as 'text/html'", function () {
props.contentType = "application/json" props.contentType = "application/json"
props.content = "<b>Result</b>" props.content = "<b>Result</b>"
const wrapper = shallow(<ResponseBody {...props}/>) const wrapper = shallow(<ResponseBody {...props} />)
expect(wrapper.find("highlightCodeComponent").length).toEqual(1) expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
}) })
it("renders ResponseBody as 'image/svg'", function() { it("renders ResponseBody as 'image/svg'", function () {
props.contentType = "image/svg" props.contentType = "image/svg"
const wrapper = shallow(<ResponseBody {...props}/>) const wrapper = shallow(<ResponseBody {...props} />)
console.warn(wrapper.debug()) console.warn(wrapper.debug())
expect(wrapper.find("highlightCodeComponent").length).toEqual(0) expect(wrapper.find("highlightCodeComponent").length).toEqual(0)
}) })
it("should render a copyable highlightCodeComponent for text types", function() { it("should render a copyable highlightCodeComponent for text types", function () {
props.contentType = "text/plain" props.contentType = "text/plain"
props.content = "test text" props.content = "test text"
const wrapper = shallow(<ResponseBody {...props}/>) const wrapper = shallow(<ResponseBody {...props} />)
console.warn(wrapper.debug()) console.warn(wrapper.debug())
expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1) expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
}) })
}) })

View File

@@ -6,56 +6,56 @@ import Response from "components/response"
import ModelExample from "components/model-example" import ModelExample from "components/model-example"
import { inferSchema } from "corePlugins/samples/fn" import { inferSchema } from "corePlugins/samples/fn"
describe("<Response />", function() { describe("<Response />", function () {
const dummyComponent = () => null const dummyComponent = () => null
const components = { const components = {
headers: dummyComponent, headers: dummyComponent,
highlightCode: dummyComponent, highlightCode: dummyComponent,
modelExample: ModelExample, modelExample: ModelExample,
Markdown: dummyComponent, Markdown: dummyComponent,
operationLink: dummyComponent, operationLink: dummyComponent,
contentType: dummyComponent contentType: dummyComponent
} }
const props = { const props = {
getComponent: c => components[c], getComponent: c => components[c],
specSelectors: { specSelectors: {
isOAS3() { isOAS3() {
return false return false
} }
}, },
fn: { fn: {
inferSchema inferSchema
}, },
contentType: "application/json", contentType: "application/json",
className: "for-test", className: "for-test",
specPath: List(), specPath: List(),
response: fromJS({ response: fromJS({
schema: { schema: {
type: "object", type: "object",
properties: { properties: {
// Note reverse order: c, b, a // Note reverse order: c, b, a
"c": { "c": {
type: "integer" type: "integer"
}, },
"b": { "b": {
type: "boolean" type: "boolean"
}, },
"a": { "a": {
type: "string" type: "string"
} }
}
} }
}), }
code: "200" }),
} code: "200"
}
it("renders the model-example schema properties in order", function() { it("renders the model-example schema properties in order", function () {
const wrapper = shallow(<Response {...props}/>) const wrapper = shallow(<Response {...props} />)
const renderedModelExample = wrapper.find(ModelExample) const renderedModelExample = wrapper.find(ModelExample)
expect(renderedModelExample.length).toEqual(1) expect(renderedModelExample.length).toEqual(1)
// Assert the schema's properties have maintained their order // Assert the schema's properties have maintained their order
const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties
expect( Object.keys(modelExampleSchemaProperties) ).toEqual(["c", "b", "a"]) expect(Object.keys(modelExampleSchemaProperties)).toEqual(["c", "b", "a"])
}) })
}) })

View File

@@ -3,206 +3,311 @@ import Im from "immutable"
import curl from "core/curlify" import curl from "core/curlify"
import win from "core/window" import win from "core/window"
describe("curlify", function() { describe("curlify", function () {
it("prints a curl statement with custom content-type", function() { it("prints a curl statement with custom content-type", function () {
var req = { var req = {
url: "http://example.com", url: "http://example.com",
method: "POST", method: "POST",
body: { body: {
id: 0, id: 0,
name: "doggie", name: "doggie",
status: "available" status: "available"
}, },
headers: { headers: {
Accept: "application/json", Accept: "application/json",
"content-type": "application/json" "content-type": "application/json"
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
})
it("does add a empty data param if no request body given", function() {
var req = {
url: "http://example.com",
method: "POST",
} }
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -d \"\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
}) })
it("does not change the case of header in curl", function() { it("does add a empty data param if no request body given", function () {
var req = { var req = {
url: "http://example.com", url: "http://example.com",
method: "POST", method: "POST",
headers: { }
"conTenT Type": "application/Moar"
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"conTenT Type: application/Moar\" -d \"\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -d \"\"")
}) })
it("prints a curl statement with an array of query params", function() { it("does not change the case of header in curl", function () {
var req = { var req = {
url: "http://swaggerhub.com/v1/one?name=john|smith", url: "http://example.com",
method: "GET" method: "POST",
} headers: {
"conTenT Type": "application/Moar"
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"conTenT Type: application/Moar\" -d \"\"")
}) })
it("prints a curl statement with an array of query params and auth", function() { it("prints a curl statement with an array of query params", function () {
var req = { var req = {
url: "http://swaggerhub.com/v1/one?name=john|smith", url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "GET", method: "GET"
headers: { }
authorization: "Basic Zm9vOmJhcg=="
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"authorization: Basic Zm9vOmJhcg==\"") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\"")
}) })
it("prints a curl statement with html", function() { it("prints a curl statement with an array of query params and auth", function () {
var req = { var req = {
url: "http://swaggerhub.com/v1/one?name=john|smith", url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "GET", method: "GET",
headers: { headers: {
accept: "application/json" authorization: "Basic Zm9vOmJhcg=="
}, }
body: { }
description: "<b>Test</b>"
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"authorization: Basic Zm9vOmJhcg==\"")
}) })
it("handles post body with html", function() { it("prints a curl statement with html", function () {
var req = { var req = {
url: "http://swaggerhub.com/v1/one?name=john|smith", url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "POST", method: "GET",
headers: { headers: {
accept: "application/json" accept: "application/json"
}, },
body: { body: {
description: "<b>Test</b>" description: "<b>Test</b>"
} }
} }
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
}) })
it("handles post body with special chars", function() { it("handles post body with html", function () {
var req = { var req = {
url: "http://swaggerhub.com/v1/one?name=john|smith", url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "POST", method: "POST",
body: { headers: {
description: "@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n" + accept: "application/json"
"@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> ." },
} body: {
} description: "<b>Test</b>"
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}") expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
}) })
it("handles delete form with parameters", function() { it("handles post body with special chars", function () {
var req = { var req = {
url: "http://example.com", url: "http://swaggerhub.com/v1/one?name=john|smith",
method: "DELETE", method: "POST",
headers: { body: {
accept: "application/x-www-form-urlencoded" description: "@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .\n" +
} "@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> ."
} }
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X DELETE \"http://example.com\" -H \"accept: application/x-www-form-urlencoded\"") expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}")
}) })
it("should print a curl with formData", function() { it("handles delete form with parameters", function () {
var req = { var req = {
url: "http://example.com", url: "http://example.com",
method: "POST", method: "DELETE",
headers: { "content-type": "multipart/form-data" }, headers: {
body: { accept: "application/x-www-form-urlencoded"
id: "123", }
name: "Sahar" }
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"name=Sahar\"") expect(curlified).toEqual("curl -X DELETE \"http://example.com\" -H \"accept: application/x-www-form-urlencoded\"")
}) })
it("should print a curl with formData that extracts array representation with hashIdx", function() { it("should print a curl with formData", function () {
// Note: hashIdx = `_**[]${counter}` var req = {
// Usage of hashIdx is an internal SwaggerUI method to convert formData array into something curlify can handle url: "http://example.com",
const req = { method: "POST",
url: "http://example.com", headers: { "content-type": "multipart/form-data" },
method: "POST", body: {
headers: { "content-type": "multipart/form-data" }, id: "123",
body: { name: "Sahar"
id: "123", }
"fruits[]_**[]1": "apple", }
"fruits[]_**[]2": "banana",
"fruits[]_**[]3": "grape"
}
}
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"fruits[]=apple\" -F \"fruits[]=banana\" -F \"fruits[]=grape\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"name=Sahar\"")
}) })
it("should print a curl with formData and file", function() { it("should print a curl with formData that extracts array representation with hashIdx", function () {
var file = new win.File() // Note: hashIdx = `_**[]${counter}`
// Usage of hashIdx is an internal SwaggerUI method to convert formData array into something curlify can handle
const req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: {
id: "123",
"fruits[]_**[]1": "apple",
"fruits[]_**[]2": "banana",
"fruits[]_**[]3": "grape"
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"fruits[]=apple\" -F \"fruits[]=banana\" -F \"fruits[]=grape\"")
})
it("should print a curl with formData and file", function () {
var file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
var req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
it("should print a curl without form data type if type is unknown", function () {
var file = new win.File()
file.name = "file.txt"
file.type = ""
var req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt\"")
})
it("prints a curl post statement from an object", function () {
var req = {
url: "http://example.com",
method: "POST",
headers: {
accept: "application/json"
},
body: {
id: 10101
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d {\"id\":10101}")
})
it("prints a curl post statement from a string containing a single quote", function () {
var req = {
url: "http://example.com",
method: "POST",
headers: {
accept: "application/json"
},
body: "{\"id\":\"foo'bar\"}"
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
})
context("given multiple entries with file", function () {
context("and with leading custom header", function () {
it("should print a proper curl -F", function () {
let file = new win.File()
file.name = "file.txt" file.name = "file.txt"
file.type = "text/plain" file.type = "text/plain"
var req = { let req = {
url: "http://example.com", url: "http://example.com",
method: "POST", method: "POST",
headers: { "content-type": "multipart/form-data" }, headers: {
body: { "x-custom-name": "multipart/form-data",
id: "123", "content-type": "multipart/form-data"
file },
} body: {
id: "123",
file
}
} }
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"x-custom-name: multipart/form-data\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
}) })
it("should print a curl without form data type if type is unknown", function() { context("and with trailing custom header; e.g. from requestInterceptor appending req.headers", function () {
var file = new win.File() it("should print a proper curl -F", function () {
file.name = "file.txt" let file = new win.File()
file.type = "" file.name = "file.txt"
file.type = "text/plain"
var req = { let req = {
url: "http://example.com",
method: "POST",
headers: {
"content-type": "multipart/form-data",
"x-custom-name": "any-value"
},
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -H \"x-custom-name: any-value\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
})
})
context("POST when header value is 'multipart/form-data' but header name is not 'content-type'", function () {
it("shoud print a proper curl as -d <data>", function () {
let file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
let req = {
url: "http://example.com", url: "http://example.com",
method: "POST", method: "POST",
headers: { "content-type": "multipart/form-data" }, headers: { "x-custom-name": "multipart/form-data" },
body: { body: {
id: "123", id: "123",
file file
@@ -211,112 +316,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"x-custom-name: multipart/form-data\" -d {\"id\":\"123\",\"file\":{\"name\":\"file.txt\",\"type\":\"text/plain\"}}")
})
it("prints a curl post statement from an object", function() {
var req = {
url: "http://example.com",
method: "POST",
headers: {
accept: "application/json"
},
body: {
id: 10101
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d {\"id\":10101}")
})
it("prints a curl post statement from a string containing a single quote", function() {
var req = {
url: "http://example.com",
method: "POST",
headers: {
accept: "application/json"
},
body: "{\"id\":\"foo'bar\"}"
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
})
context("given multiple entries with file", function() {
context("and with leading custom header", function() {
it("should print a proper curl -F", function() {
let file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
let req = {
url: "http://example.com",
method: "POST",
headers: {
"x-custom-name": "multipart/form-data",
"content-type": "multipart/form-data"
},
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"x-custom-name: multipart/form-data\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
})
context("and with trailing custom header; e.g. from requestInterceptor appending req.headers", function() {
it("should print a proper curl -F", function() {
let file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
let req = {
url: "http://example.com",
method: "POST",
headers: {
"content-type": "multipart/form-data",
"x-custom-name": "any-value"
},
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -H \"x-custom-name: any-value\" -F \"id=123\" -F \"file=@file.txt;type=text/plain\"")
})
})
})
context("POST when header value is 'multipart/form-data' but header name is not 'content-type'", function() {
it("shoud print a proper curl as -d <data>", function() {
let file = new win.File()
file.name = "file.txt"
file.type = "text/plain"
let req = {
url: "http://example.com",
method: "POST",
headers: { "x-custom-name": "multipart/form-data" },
body: {
id: "123",
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"x-custom-name: multipart/form-data\" -d {\"id\":\"123\",\"file\":{\"name\":\"file.txt\",\"type\":\"text/plain\"}}")
})
}) })
})
}) })