Skip to content

Commit

Permalink
Merge pull request #1567 from cosmos/fedekunze/split-refactors-from-1522
Browse files Browse the repository at this point in the history
David/split refactors from 1522
  • Loading branch information
faboweb authored Nov 14, 2018
2 parents a6787d6 + c488247 commit b64f922
Show file tree
Hide file tree
Showing 8 changed files with 1,729 additions and 271 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1482](https://github.com/cosmos/voyager/issues/1482) Added ESLint errors: no-var. @sgobotta
* [\#1449](https://github.com/cosmos/voyager/issues/1449) shortNumber to num scripts for more readable numbers. @jbibla
* [\#1464](https://github.com/cosmos/voyager/issues/1464) Added governance transactions to tx history page @fedekunze
* [\1401](https://github.com/cosmos/voyager/issues/1401) Display governance proposals index. @fedekunze
* [\#1401](https://github.com/cosmos/voyager/issues/1401) Display governance proposals index. @fedekunze
* [\#1472](https://github.com/cosmos/voyager/issues/1472) Added mock functionality for redelegation @fedekunze + @faboweb
* [\#1501](https://github.com/cosmos/voyager/issues/1501) Vote on proposals through modal @fedekunze + @jbibla
* [\1502](https://github.com/cosmos/voyager/issues/1502) A page for each proposal. @jbibla
* [\1552](https://github.com/cosmos/voyager/issues/1522) Deposit on proposals through modal @fedekunze
* [\1548](https://github.com/cosmos/voyager/issues/1548) Add mocked deposit for testing @fedekunze
* [\1116](https://github.com/cosmos/voyager/issues/1116) Elaborate a bit about the release process. @NodeGuy
* [\1568](https://github.com/cosmos/voyager/issues/1568) Add mocked submit deposit for testing @fedekunze
* [\#1567](https://github.com/cosmos/voyager/pull/1567) Various refactors on `main`, `node` and `lcdClient`. @NodeGuy
* [\#1502](https://github.com/cosmos/voyager/issues/1502) A page for each proposal. @jbibla
* [\#1552](https://github.com/cosmos/voyager/issues/1522) Deposit on proposals through modal @fedekunze
* [\#1548](https://github.com/cosmos/voyager/issues/1548) Add mocked deposit for testing @fedekunze
* [\#1116](https://github.com/cosmos/voyager/issues/1116) Elaborate a bit about the release process. @NodeGuy
* [\#1568](https://github.com/cosmos/voyager/issues/1568) Add mocked submit proposal for testing @fedekunze

### Changed

Expand Down
8 changes: 2 additions & 6 deletions app/src/renderer/connectors/lcdClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Client = (axios, localLcdURL, remoteLcdURL) => {
async function request(method, path, data, useRemote) {
const url = useRemote ? remoteLcdURL : localLcdURL
return (await axios[method.toLowerCase()](url + path, data)).data
return (await axios({ data, method, url: url + path })).data
}

// returns an async function which makes a request for the given
Expand All @@ -23,9 +23,7 @@ const Client = (axios, localLcdURL, remoteLcdURL) => {
if (Array.isArray(args)) {
args = args.join(`/`)
}
if (method === `DELETE`) {
data = { data }
}

return request(method, `${prefix}/${args}${suffix}`, data, useRemote)
}
}
Expand All @@ -34,8 +32,6 @@ const Client = (axios, localLcdURL, remoteLcdURL) => {

const keys = {
add: req(`POST`, `/keys`),

// axios handles DELETE requests different then other requests, we have to but the body in a config object with the prop data
delete: argReq(`DELETE`, `/keys`),

get: async key => {
Expand Down
3 changes: 1 addition & 2 deletions app/src/renderer/connectors/node.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use strict"

const axios = require(`axios`)
const RestClient = require(`./lcdClient.js`)
const mockedRestClient = require(`./lcdClientMock.js`)
const RpcWrapper = require(`./rpcWrapper.js`)
const MockedRpcWrapper = require(`./rpcWrapperMock.js`)

module.exports = function(localLcdURL, remoteLcdURL, mocked = false) {
module.exports = function(axios, localLcdURL, remoteLcdURL, mocked = false) {
let connector = {
mocked,
localLcdURL,
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict"

import axios from "axios"
import Vue from "vue"
import Electron from "vue-electron"
import Router from "vue-router"
Expand Down Expand Up @@ -69,7 +70,7 @@ async function main() {
let lcdPort = getQueryParameter(`lcd_port`)
let localLcdURL = `http://localhost:${lcdPort}`
console.log(`Expecting lcd-server on port: ` + lcdPort)
node = Node(localLcdURL, config.node_lcd, config.mocked)
node = Node(axios, localLcdURL, config.node_lcd, config.mocked)

store = Store({ node })
store.dispatch(`loadTheme`)
Expand Down
6 changes: 2 additions & 4 deletions test/unit/specs/App.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use strict"

/* mocking electron differently in one file apparently didn't work so I had to split the App tests in 2 files */

jest.mock(
Expand Down Expand Up @@ -59,11 +57,11 @@ describe(`App without analytics`, () => {
})
let Node = require(`renderer/connectors/node.js`)
require(`renderer/main.js`)
expect(Node).toHaveBeenCalledWith(
expect(Node.mock.calls[0].slice(1)).toEqual([
`http://localhost:8080`,
`https://awesomenode.de:12345`,
true
)
])
jest.resetModules()
})

Expand Down
Loading

0 comments on commit b64f922

Please sign in to comment.