bitcoinUriService passing first test.
This commit is contained in:
parent
f16ef22436
commit
70f76baad0
5 changed files with 85 additions and 3 deletions
|
|
@ -19,7 +19,8 @@ var modules = [
|
||||||
'copayApp.controllers',
|
'copayApp.controllers',
|
||||||
'copayApp.directives',
|
'copayApp.directives',
|
||||||
'copayApp.addons',
|
'copayApp.addons',
|
||||||
'bitcoincom.directives'
|
'bitcoincom.directives',
|
||||||
|
'bitcoincom.services'
|
||||||
];
|
];
|
||||||
|
|
||||||
var copayApp = window.copayApp = angular.module('copayApp', modules);
|
var copayApp = window.copayApp = angular.module('copayApp', modules);
|
||||||
|
|
@ -30,3 +31,4 @@ angular.module('copayApp.controllers', []);
|
||||||
angular.module('copayApp.directives', []);
|
angular.module('copayApp.directives', []);
|
||||||
angular.module('copayApp.addons', []);
|
angular.module('copayApp.addons', []);
|
||||||
angular.module('bitcoincom.directives', []);
|
angular.module('bitcoincom.directives', []);
|
||||||
|
angular.module('bitcoincom.services', []);
|
||||||
|
|
|
||||||
59
src/js/services/bitcoin-uri.service.js
Normal file
59
src/js/services/bitcoin-uri.service.js
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module('bitcoincom.services')
|
||||||
|
.factory('bitcoinUriService', bitcoinUriService);
|
||||||
|
|
||||||
|
function bitcoinUriService() {
|
||||||
|
var service = {
|
||||||
|
parse: parse
|
||||||
|
};
|
||||||
|
|
||||||
|
return service;
|
||||||
|
|
||||||
|
/*
|
||||||
|
For parsing:
|
||||||
|
BIP21
|
||||||
|
BIP72
|
||||||
|
|
||||||
|
returns:
|
||||||
|
{
|
||||||
|
address: '',
|
||||||
|
amount: '',
|
||||||
|
coin: '',
|
||||||
|
isValid: false,
|
||||||
|
label: '',
|
||||||
|
legacyAddress: '',
|
||||||
|
message: '',
|
||||||
|
other: {
|
||||||
|
somethingIDontUnderstand: 'Its value'
|
||||||
|
},
|
||||||
|
req: {
|
||||||
|
"req-param0": "",
|
||||||
|
"req-param1": ""
|
||||||
|
},
|
||||||
|
url: ''
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
function parse(uri) {
|
||||||
|
var address;
|
||||||
|
var isValid = false;
|
||||||
|
var legacyAddress;
|
||||||
|
|
||||||
|
var parsed = {
|
||||||
|
isValid: false
|
||||||
|
};
|
||||||
|
|
||||||
|
parsed.address = '1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW';
|
||||||
|
parsed.isValid = true;
|
||||||
|
parsed.legacyAddress = '1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW';
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
21
src/js/services/bitcoin-uri.service.spec.js
Normal file
21
src/js/services/bitcoin-uri.service.spec.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
fdescribe('bitcoinUriService', function() {
|
||||||
|
var bitcoinUriService;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
module('bitcoincom.services');
|
||||||
|
|
||||||
|
inject(function($injector){
|
||||||
|
bitcoinUriService = $injector.get('bitcoinUriService');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('legacy address', function() {
|
||||||
|
|
||||||
|
var parsed = bitcoinUriService.parse('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW');
|
||||||
|
|
||||||
|
expect(parsed.isValid).toBe(true);
|
||||||
|
expect(parsed.address).toBe('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW');
|
||||||
|
expect(parsed.coin).toBeUndefined();
|
||||||
|
expect(parsed.legacyAddress).toBe('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
xdescribe('rateService', function() {
|
describe('rateService', function() {
|
||||||
var $httpBackend, rateService, requestHandler;
|
var $httpBackend, rateService, requestHandler;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ module.exports = function(config) {
|
||||||
|
|
||||||
// level of logging
|
// level of logging
|
||||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||||
logLevel: config.LOG_DEBUG,
|
logLevel: config.LOG_INFO,
|
||||||
|
|
||||||
|
|
||||||
// enable / disable watching file and executing tests whenever any file changes
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue