test: address trim transform options
This commit is contained in:
parent
5e72240be9
commit
5eb32cf64c
@ -169,6 +169,14 @@ AddressController.prototype.transformUtxo = function(utxoArg) {
|
|||||||
return utxo;
|
return utxo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AddressController.prototype._getTransformOptions = function(req) {
|
||||||
|
return {
|
||||||
|
noAsm: parseInt(req.query.noAsm) ? true : false,
|
||||||
|
noScriptSig: parseInt(req.query.noScriptSig) ? true : false,
|
||||||
|
noSpent: parseInt(req.query.noSpent) ? true : false
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
AddressController.prototype.multitxs = function(req, res, next) {
|
AddressController.prototype.multitxs = function(req, res, next) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -183,11 +191,7 @@ AddressController.prototype.multitxs = function(req, res, next) {
|
|||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
var transformOptions = {
|
var transformOptions = self._getTransformOptions(req);
|
||||||
noAsm: req.query.noAsm ? true : false,
|
|
||||||
noScriptSig: req.query.noScriptSig ? true : false,
|
|
||||||
noSpent: req.query.noSpent ? true : false
|
|
||||||
};
|
|
||||||
|
|
||||||
self.transformAddressHistoryForMultiTxs(result.items, transformOptions, function(err, items) {
|
self.transformAddressHistoryForMultiTxs(result.items, transformOptions, function(err, items) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@ -714,4 +714,57 @@ describe('Addresses', function() {
|
|||||||
addresses.multitxs(req, res);
|
addresses.multitxs(req, res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('#_getTransformOptions', function() {
|
||||||
|
it('will return false with value of string "0"', function() {
|
||||||
|
var node = {};
|
||||||
|
var addresses = new AddressController(node);
|
||||||
|
var req = {
|
||||||
|
query: {
|
||||||
|
noAsm: '0',
|
||||||
|
noScriptSig: '0',
|
||||||
|
noSpent: '0'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var options = addresses._getTransformOptions(req);
|
||||||
|
options.should.eql({
|
||||||
|
noAsm: false,
|
||||||
|
noScriptSig: false,
|
||||||
|
noSpent: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('will return true with value of string "1"', function() {
|
||||||
|
var node = {};
|
||||||
|
var addresses = new AddressController(node);
|
||||||
|
var req = {
|
||||||
|
query: {
|
||||||
|
noAsm: '1',
|
||||||
|
noScriptSig: '1',
|
||||||
|
noSpent: '1'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var options = addresses._getTransformOptions(req);
|
||||||
|
options.should.eql({
|
||||||
|
noAsm: true,
|
||||||
|
noScriptSig: true,
|
||||||
|
noSpent: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('will return true with value of number "1"', function() {
|
||||||
|
var node = {};
|
||||||
|
var addresses = new AddressController(node);
|
||||||
|
var req = {
|
||||||
|
query: {
|
||||||
|
noAsm: 1,
|
||||||
|
noScriptSig: 1,
|
||||||
|
noSpent: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var options = addresses._getTransformOptions(req);
|
||||||
|
options.should.eql({
|
||||||
|
noAsm: true,
|
||||||
|
noScriptSig: true,
|
||||||
|
noSpent: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user