-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet: fix repair 0 bid and add unit test (#277)
- Loading branch information
1 parent
2706351
commit 7a25873
Showing
12 changed files
with
1,711 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,4 @@ dll | |
.idea | ||
*.iml | ||
npm-debug.log.* | ||
test-dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
const test = require('tape'); | ||
const sinon = require('sinon'); | ||
import {mount} from 'enzyme'; | ||
import {RepairBid} from "../RepairBid"; | ||
import {createMockStore} from "../../../utils/test-helpers"; | ||
|
||
test('<RepairBid>', async t => { | ||
const getNameInfoStub = sinon.stub(); | ||
const showErrorStub = sinon.stub(); | ||
const store = createMockStore(); | ||
let calls = 0; | ||
const wrapper = mount( | ||
<RepairBid | ||
bid={{ | ||
name: 'test', | ||
from: 'ts1q8tlzrx9lq9an302cju5q6msjnr06564sd9fnj9' | ||
}} | ||
getNameInfo={getNameInfoStub} | ||
showError={showErrorStub} | ||
store={store} | ||
/>, | ||
); | ||
|
||
const verifyBidSpy = sinon.stub(RepairBid.prototype, 'verifyBid'); | ||
|
||
const div = wrapper.find('div').at(0); | ||
div.props().onClick(); | ||
|
||
wrapper.update(); | ||
|
||
testOneRepair('1234'); | ||
testOneRepair('0'); | ||
|
||
t.end(); | ||
|
||
function testOneRepair(text) { | ||
const input = wrapper.find('input').at(0); | ||
input.props().onChange({ | ||
target: { | ||
value: `${text}`, | ||
}, | ||
}); | ||
|
||
wrapper.update(); | ||
|
||
t.equal( | ||
verifyBidSpy.getCall(calls++).args[0], | ||
Number(text), | ||
`it should submit verifyBid for ${text}`, | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import sinon from 'sinon'; | ||
|
||
export const createMockStore = (initialState = {}) => { | ||
return { | ||
getState: () => initialState, | ||
subscribe: sinon.stub(), | ||
dispatch: sinon.stub(), | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
import webpack from "webpack"; | ||
|
||
const path = require('path'); | ||
|
||
module.exports = { | ||
devtool: 'inline-source-map', | ||
|
||
mode: 'development', | ||
target: 'electron-renderer', | ||
entry: [ | ||
'./unit.js', | ||
], | ||
output: { | ||
path: path.resolve(__dirname, '../test-dist'), | ||
filename: 'test.js' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: true | ||
} | ||
} | ||
}, | ||
{ | ||
test: /\.global\.css$/, | ||
use: [ | ||
{ | ||
loader: 'style-loader' | ||
}, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
sourceMap: true | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
test: /^((?!\.global).)*\.css$/, | ||
use: [ | ||
{ | ||
loader: 'style-loader' | ||
}, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: true, | ||
sourceMap: true, | ||
importLoaders: 1, | ||
localIdentName: '[name]__[local]__[hash:base64:5]' | ||
} | ||
} | ||
] | ||
}, | ||
// SASS support - compile all .global.scss files and pipe it to style.css | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
{ | ||
loader: 'style-loader' | ||
}, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
sourceMap: true | ||
} | ||
}, | ||
{ | ||
loader: 'sass-loader' | ||
} | ||
] | ||
}, | ||
// WOFF Font | ||
{ | ||
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, | ||
use: { | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
mimetype: 'application/font-woff' | ||
} | ||
} | ||
}, | ||
// WOFF2 Font | ||
{ | ||
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, | ||
use: { | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
mimetype: 'application/font-woff' | ||
} | ||
} | ||
}, | ||
// TTF Font | ||
{ | ||
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, | ||
use: { | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
mimetype: 'application/octet-stream' | ||
} | ||
} | ||
}, | ||
// EOT Font | ||
{ | ||
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, | ||
use: 'file-loader' | ||
}, | ||
// SVG Font | ||
{ | ||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, | ||
use: { | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
mimetype: 'image/svg+xml' | ||
} | ||
} | ||
}, | ||
// Common Image Formats | ||
{ | ||
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/, | ||
use: 'url-loader' | ||
} | ||
] | ||
}, | ||
|
||
plugins: [ | ||
/** | ||
* Create global constants which can be configured at compile time. | ||
* | ||
* Useful for allowing different behaviour between development builds and | ||
* release builds | ||
* | ||
* NODE_ENV should be production so that modules do not perform certain | ||
* development checks | ||
* | ||
* By default, use 'development' as NODE_ENV. This can be overriden with | ||
* 'staging', for example, by changing the ENV variables in the npm scripts | ||
*/ | ||
new webpack.EnvironmentPlugin({ | ||
NODE_ENV: 'development' | ||
}), | ||
new webpack.LoaderOptionsPlugin({ | ||
debug: true | ||
}) | ||
], | ||
|
||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
}; |
Oops, something went wrong.