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

some wallet tests #58

Closed
wants to merge 11 commits into from
Closed
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ $ npm run pack
$ npm run test
```

To see where you are missing coverage, run a test first and then open an http-server at `test/unit/coverage/lcov-report` to see details for the coverage.
i.e.:

```bash
$ npm i -g http-server
$ http-server test/unit/coverage/lcov-report
```

## FAQ

Expand Down
122 changes: 6 additions & 116 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/renderer/components/wallet/PageBalances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default {
...mapGetters(['filters', 'wallet']),
filteredBalances () {
let query = this.filters.balances.search.query
let list = orderBy(this.wallet.balances, ['denom', 'desc'])
let list = orderBy(this.wallet.balances, ['denom'], ['desc'])
if (this.filters.balances.search.visible) {
return list.filter(i => includes(i.denom.toLowerCase(), query))
} else {
Expand Down
5 changes: 1 addition & 4 deletions app/src/renderer/components/wallet/PageReceive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export default {
CardNew
},
computed: {
...mapGetters([
'allAddresses',
'allWallets'
]),
...mapGetters(['allAddresses', 'allWallets']),
addresses () {
return this.allAddresses.slice().reverse()
},
Expand Down
1 change: 0 additions & 1 deletion app/src/renderer/vuex/modules/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default ({ commit, basecoin }) => {
state[type].search.visible = bool
},
setSearchQuery (state, [type, string]) {
console.log('setSearchQuery', type, string)
state[type].search.query = string
}
}
Expand Down
25 changes: 12 additions & 13 deletions app/src/renderer/vuex/modules/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const files = require.context('.', false, /\.js$/)
const funcs = {}
files.keys().forEach((key) => {
if (key === './index.js') return
funcs[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
export default (opts) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require.context is not available in jest (comment on that from the lead dev of jest: facebook/create-react-app#517 (comment))

candidates: require('./candidates.js').default(opts),
config: require('./config.js').default(opts),
delegators: require('./delegators.js').default(opts),
filters: require('./filters.js').default(opts),
node: require('./node.js').default(opts),
notifications: require('./notifications.js').default(opts),
proposals: require('./proposals.js').default(opts),
shoppingCart: require('./shoppingCart.js').default(opts),
user: require('./user.js').default(opts),
validators: require('./validators.js').default(opts),
wallet: require('./wallet.js').default(opts)
})

export default (opts) => {
const modules = {}
for (let key in funcs) {
modules[key] = funcs[key](opts)
}
return modules
}
1 change: 1 addition & 0 deletions app/src/renderer/vuex/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Vue.use(Vuex)

export default (opts = {}) => {
opts.commit = (...args) => store.commit(...args)

var store = new Vuex.Store({
actions,
getters,
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@
"tape-promise": "^2.0.1",
"tree-kill": "^1.1.0",
"url-loader": "^0.5.7",
"vue": "^2.5.3",
"vue-hot-reload-api": "^2.0.7",
"vue-html-loader": "^1.2.2",
"vue-loader": "^10.0.2",
"vue-loader": "^13.5.0",
"vue-style-loader": "^1.0.0",
"vue-template-compiler": "^2.1.10",
"vue-template-compiler": "^2.5.3",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0",
"webpack-merge": "^0.14.1"
Expand All @@ -102,7 +103,10 @@
"@nylira/vue-notifications": "^1.3.0",
"axios": "^0.17.0",
"babel-jest": "^21.2.0",
"bs58check": "^2.0.2",
"chart.js": "^2.6.0",
"cosmos-delegation-game": "^0.1.2",
"cosmos-fundraiser": "^7.14.5",
"electron": "^1.7.5",
"flatpickr": "^4.0.6",
"fs-extra": "^4.0.2",
Expand All @@ -120,8 +124,12 @@
"superagent": "^3.5.2",
"tail": "^1.2.1",
"tendermint-crypto": "github:mappum/js-crypto",
"vue-test-utils": "^1.0.0-beta.4",
"vuelidate": "^0.5.0",
"websocket-extensions": "^0.1.2"
"vuex": "^3.0.1",
"web3": "^1.0.0-beta.24",
"websocket-extensions": "^0.1.2",
"xmlhttprequest": "^1.8.0"
},
"jest": {
"testMatch": [
Expand All @@ -135,6 +143,9 @@
"node_modules",
"src"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/app/src/$1"
},
"transform": {
".*.vue$": "jest-vue-preprocessor",
".*.js$": "babel-jest"
Expand All @@ -155,6 +166,9 @@
"/test/",
"/config/"
],
"testURL": "http://localhost"
"testURL": "http://localhost",
"setupFiles": [
"./test/unit/helpers/setup.js"
]
}
}
4 changes: 4 additions & 0 deletions test/unit/helpers/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import xmlhttprequest from 'xmlhttprequest'

// providing the browser XMLHttpRequest in the node.js process of jest where it is not available
global.XMLHttpRequest = xmlhttprequest.XMLHttpRequest
18 changes: 18 additions & 0 deletions test/unit/specs/CardAddress.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Vue from 'vue'
import CardAddress from '../../../app/src/renderer/components/wallet/CardAddress'

describe('CardAddress', () => {
let Cmp, vm
let propsData = {
address: 12345678
}

beforeEach(() => {
Cmp = Vue.extend(CardAddress)
vm = new Cmp({ propsData: propsData }).$mount()
})

it('has the expected html structure', () => {
expect(vm.$el).toMatchSnapshot()
})
})
21 changes: 21 additions & 0 deletions test/unit/specs/CardBalance.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Vue from 'vue'
import CardBalance from '../../../app/src/renderer/components/wallet/CardBalance'

describe('CardBalance', () => {
let Cmp, vm
let propsData = {
balance: {
denom: 'jbcoin',
amount: 1234.56
}
}

beforeEach(() => {
Cmp = Vue.extend(CardBalance)
vm = new Cmp({ propsData: propsData }).$mount()
})

it('has the expected html structure', () => {
expect(vm.$el).toMatchSnapshot()
})
})
19 changes: 19 additions & 0 deletions test/unit/specs/CardNew.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Vue from 'vue'
import CardNew from '../../../app/src/renderer/components/wallet/CardNew'

describe('CardNew', () => {
let Cmp, vm
let propsData = {
icon: 'taco',
value: 12345678
}

beforeEach(() => {
Cmp = Vue.extend(CardNew)
vm = new Cmp({ propsData: propsData }).$mount()
})

it('has the expected html structure', () => {
expect(vm.$el).toMatchSnapshot()
})
})
Loading