From a17239ca311f79dd4a782a10bf1dd709ff1e765d Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Mon, 25 Nov 2019 05:44:44 +0530 Subject: [PATCH 1/2] :recycle: Refactoring code --- build.js | 2 +- layouts/default.vue | 2 +- pages/index.vue | 8 ++++---- pages/realtime.vue | 2 +- pages/settings.vue | 2 +- tests/e2e/integration/feature.url-queries.spec.js | 14 +++++++------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.js b/build.js index ea7d91426..85fd72dcd 100644 --- a/build.js +++ b/build.js @@ -28,7 +28,7 @@ try { version.name = (await axios .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 - .catch(ex => ({ + .catch((ex) => ({ data: [{ tag_name: require("./package.json").version }] diff --git a/layouts/default.vue b/layouts/default.vue index e13d12aae..fc102612b 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -373,7 +373,7 @@ export default { // Load theme color data from settings, or use default color. let color = this.$store.state.postwoman.settings.THEME_COLOR || "#50fa7b"; let vibrant = this.$store.state.postwoman.settings.THEME_COLOR_VIBRANT; - if (vibrant == null) vibrant = true; + if (vibrant === null) vibrant = true; document.documentElement.style.setProperty("--ac-color", color); document.documentElement.style.setProperty( "--act-color", diff --git a/pages/index.vue b/pages/index.vue index b8e719b3b..3f7bf29e6 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1231,7 +1231,7 @@ export default { ); } if (this.headers) { - this.headers.forEach(function(element) { + this.headers.forEach((element) => { requestString.push( "xhr.setRequestHeader('" + element.key + @@ -1288,7 +1288,7 @@ export default { ); } if (this.headers) { - this.headers.forEach(function(element) { + this.headers.forEach((element) => { headers.push( ' "' + element.key + '": "' + element.value + '",\n' ); @@ -1326,7 +1326,7 @@ export default { ); } if (this.headers) { - this.headers.forEach(function(element) { + this.headers.forEach((element) => { requestString.push( " -H '" + element.key + ": " + element.value + "' \\\n" ); @@ -1966,7 +1966,7 @@ export default { uploadPayload() { this.rawInput = true; let file = this.$refs.payload.files[0]; - if (file != null) { + if (file !== null) { let reader = new FileReader(); reader.onload = e => { this.rawParams = e.target.result; diff --git a/pages/realtime.vue b/pages/realtime.vue index bbf2eee0c..df0186591 100644 --- a/pages/realtime.vue +++ b/pages/realtime.vue @@ -295,7 +295,7 @@ export default { } }, disconnect() { - if (this.socket !== null) this.socket.close(); + this.socket.close(); }, handleError(error) { this.disconnect(); diff --git a/pages/settings.vue b/pages/settings.vue index c8c8c5866..54a3f4ae0 100644 --- a/pages/settings.vue +++ b/pages/settings.vue @@ -244,7 +244,7 @@ export default { }, setActiveColor(color, 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( "--act-color", diff --git a/tests/e2e/integration/feature.url-queries.spec.js b/tests/e2e/integration/feature.url-queries.spec.js index 92c15125c..d78350db5 100644 --- a/tests/e2e/integration/feature.url-queries.spec.js +++ b/tests/e2e/integration/feature.url-queries.spec.js @@ -1,6 +1,6 @@ describe('Methods', () => { 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`, () => { cy.visit(`/?method=${method}`) .get('#method').contains(method) @@ -11,8 +11,8 @@ describe('Methods', () => { describe('Url and path', () => { 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=') - .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('#url').then((el) => expect(el.val() === 'https://api.thecatapi.com').to.equal(true)) + .get("#path").then((el) => expect(el.val() === '').to.equal(true)) .get('#response-details-wrapper').should($wrapper => { 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`, () => { cy.visit(`?&auth=Basic&httpUser=foo&httpPassword=bar`, { retryOnStatusCodeFailure: true }) .get('#authentication').contains('Authentication').click() - .then(() => { + .then(() => { cy.get('input[name="http_basic_user"]', { timeout: 500 }) .invoke('val') - .then(user => { + .then((user) => { expect(user === 'foo').to.equal(true) cy.log('Success! user === foo') }) cy.get('input[name="http_basic_passwd"]') .invoke('val') - .then(user => { + .then((user) => { expect(user === 'bar').to.equal(true) cy.log('Success! password === bar') }) @@ -48,7 +48,7 @@ describe('Authentication', () => { .then(() => { cy.get('input[name="bearer_token"]', { timeout: 500 }) .invoke('val') - .then(tkn => { + .then((tkn) => { expect(tkn === base64Tkn).to.equal(true) cy.log(`Success! input[name="bearer_token"] === ${base64Tkn}`) }) From f623b3122093e178930ea8308251e0cbf98a83df Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Mon, 25 Nov 2019 05:51:48 +0530 Subject: [PATCH 2/2] :recycle: Refactoring code --- layouts/default.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/default.vue b/layouts/default.vue index fc102612b..e13d12aae 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -373,7 +373,7 @@ export default { // Load theme color data from settings, or use default color. let color = this.$store.state.postwoman.settings.THEME_COLOR || "#50fa7b"; let vibrant = this.$store.state.postwoman.settings.THEME_COLOR_VIBRANT; - if (vibrant === null) vibrant = true; + if (vibrant == null) vibrant = true; document.documentElement.style.setProperty("--ac-color", color); document.documentElement.style.setProperty( "--act-color",