Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

David/split refactors from 1522 #1567

Merged
merged 19 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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([
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
`http://localhost:8080`,
`https://awesomenode.de:12345`,
true
)
])
jest.resetModules()
})

Expand Down
Loading