Refactoring code (#332)
Refactoring code Co-authored-by: Liyas Thomas <liyasthomas@gmail.com>
This commit is contained in:
2
build.js
2
build.js
@@ -28,7 +28,7 @@ try {
|
|||||||
version.name = (await axios
|
version.name = (await axios
|
||||||
.get("https://api.github.com/repos/liyasthomas/postwoman/releases")
|
.get("https://api.github.com/repos/liyasthomas/postwoman/releases")
|
||||||
// If we can't get it from GitHub, we'll resort to getting it from package.json
|
// If we can't get it from GitHub, we'll resort to getting it from package.json
|
||||||
.catch(ex => ({
|
.catch((ex) => ({
|
||||||
data: [{
|
data: [{
|
||||||
tag_name: require("./package.json").version
|
tag_name: require("./package.json").version
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -1231,7 +1231,7 @@ export default {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
this.headers.forEach(function(element) {
|
this.headers.forEach((element) => {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
"xhr.setRequestHeader('" +
|
"xhr.setRequestHeader('" +
|
||||||
element.key +
|
element.key +
|
||||||
@@ -1288,7 +1288,7 @@ export default {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
this.headers.forEach(function(element) {
|
this.headers.forEach((element) => {
|
||||||
headers.push(
|
headers.push(
|
||||||
' "' + element.key + '": "' + element.value + '",\n'
|
' "' + element.key + '": "' + element.value + '",\n'
|
||||||
);
|
);
|
||||||
@@ -1326,7 +1326,7 @@ export default {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
this.headers.forEach(function(element) {
|
this.headers.forEach((element) => {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H '" + element.key + ": " + element.value + "' \\\n"
|
" -H '" + element.key + ": " + element.value + "' \\\n"
|
||||||
);
|
);
|
||||||
@@ -1966,7 +1966,7 @@ export default {
|
|||||||
uploadPayload() {
|
uploadPayload() {
|
||||||
this.rawInput = true;
|
this.rawInput = true;
|
||||||
let file = this.$refs.payload.files[0];
|
let file = this.$refs.payload.files[0];
|
||||||
if (file != null) {
|
if (file !== null) {
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = e => {
|
reader.onload = e => {
|
||||||
this.rawParams = e.target.result;
|
this.rawParams = e.target.result;
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
disconnect() {
|
disconnect() {
|
||||||
if (this.socket !== null) this.socket.close();
|
this.socket.close();
|
||||||
},
|
},
|
||||||
handleError(error) {
|
handleError(error) {
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ export default {
|
|||||||
},
|
},
|
||||||
setActiveColor(color, vibrant) {
|
setActiveColor(color, vibrant) {
|
||||||
// By default, the color is vibrant.
|
// By default, the color is vibrant.
|
||||||
if (vibrant == null) vibrant = true;
|
if (vibrant === null) vibrant = true;
|
||||||
document.documentElement.style.setProperty("--ac-color", color);
|
document.documentElement.style.setProperty("--ac-color", color);
|
||||||
document.documentElement.style.setProperty(
|
document.documentElement.style.setProperty(
|
||||||
"--act-color",
|
"--act-color",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('Methods', () => {
|
describe('Methods', () => {
|
||||||
const methods = [ 'POST', 'HEAD', 'POST', 'PUT', 'DELETE','OPTIONS', 'PATCH']
|
const methods = [ 'POST', 'HEAD', 'POST', 'PUT', 'DELETE','OPTIONS', 'PATCH']
|
||||||
methods.forEach(method => {
|
methods.forEach((method) => {
|
||||||
it(`Change the default method GET to ${method} with url query`, () => {
|
it(`Change the default method GET to ${method} with url query`, () => {
|
||||||
cy.visit(`/?method=${method}`)
|
cy.visit(`/?method=${method}`)
|
||||||
.get('#method').contains(method)
|
.get('#method').contains(method)
|
||||||
@@ -11,8 +11,8 @@ describe('Methods', () => {
|
|||||||
describe('Url and path', () => {
|
describe('Url and path', () => {
|
||||||
it('Change default url with query and reset default path to empty string and make a request to cat api', () => {
|
it('Change default url with query and reset default path to empty string and make a request to cat api', () => {
|
||||||
cy.seedAndVisit('catapi', '/?url=https://api.thecatapi.com&path=')
|
cy.seedAndVisit('catapi', '/?url=https://api.thecatapi.com&path=')
|
||||||
.get('#url').then(el => expect(el.val() === 'https://api.thecatapi.com').to.equal(true))
|
.get('#url').then((el) => expect(el.val() === 'https://api.thecatapi.com').to.equal(true))
|
||||||
.get("#path").then(el => expect(el.val() === '').to.equal(true))
|
.get("#path").then((el) => expect(el.val() === '').to.equal(true))
|
||||||
.get('#response-details-wrapper').should($wrapper => {
|
.get('#response-details-wrapper').should($wrapper => {
|
||||||
expect($wrapper).to.contain('FAKE Cat API')
|
expect($wrapper).to.contain('FAKE Cat API')
|
||||||
})
|
})
|
||||||
@@ -23,17 +23,17 @@ describe('Authentication', () => {
|
|||||||
it(`Change default auth 'None' to 'Basic' and set httpUser and httpPassword with url query`, () => {
|
it(`Change default auth 'None' to 'Basic' and set httpUser and httpPassword with url query`, () => {
|
||||||
cy.visit(`?&auth=Basic&httpUser=foo&httpPassword=bar`, { retryOnStatusCodeFailure: true })
|
cy.visit(`?&auth=Basic&httpUser=foo&httpPassword=bar`, { retryOnStatusCodeFailure: true })
|
||||||
.get('#authentication').contains('Authentication').click()
|
.get('#authentication').contains('Authentication').click()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.get('input[name="http_basic_user"]', { timeout: 500 })
|
cy.get('input[name="http_basic_user"]', { timeout: 500 })
|
||||||
.invoke('val')
|
.invoke('val')
|
||||||
.then(user => {
|
.then((user) => {
|
||||||
expect(user === 'foo').to.equal(true)
|
expect(user === 'foo').to.equal(true)
|
||||||
cy.log('Success! user === foo')
|
cy.log('Success! user === foo')
|
||||||
})
|
})
|
||||||
|
|
||||||
cy.get('input[name="http_basic_passwd"]')
|
cy.get('input[name="http_basic_passwd"]')
|
||||||
.invoke('val')
|
.invoke('val')
|
||||||
.then(user => {
|
.then((user) => {
|
||||||
expect(user === 'bar').to.equal(true)
|
expect(user === 'bar').to.equal(true)
|
||||||
cy.log('Success! password === bar')
|
cy.log('Success! password === bar')
|
||||||
})
|
})
|
||||||
@@ -48,7 +48,7 @@ describe('Authentication', () => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
cy.get('input[name="bearer_token"]', { timeout: 500 })
|
cy.get('input[name="bearer_token"]', { timeout: 500 })
|
||||||
.invoke('val')
|
.invoke('val')
|
||||||
.then(tkn => {
|
.then((tkn) => {
|
||||||
expect(tkn === base64Tkn).to.equal(true)
|
expect(tkn === base64Tkn).to.equal(true)
|
||||||
cy.log(`Success! input[name="bearer_token"] === ${base64Tkn}`)
|
cy.log(`Success! input[name="bearer_token"] === ${base64Tkn}`)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user