This commit is contained in:
Javier 2016-06-14 12:01:18 -03:00
parent 9163127dca
commit bab8b4c3ff
4 changed files with 16 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<div class="content preferences" ng-controller="preferencesHistory">
<h4></h4>
<ul class="no-bullet m0" ng-if="!index.isCordova" ng-init="csvHistory(index.updatingTxHistory)">
<ul class="no-bullet m0" ng-if="!index.isCordova" ng-init="index.updatingTxHistory ? null : csvHistory()">
<li ng-if="csvReady">
<a ng-csv="csvContent" csv-header="csvHeader" ng-style="{'color':index.backgroundColor}"
filename="Copay-{{index.alias || index.walletName}}.csv" translate>Export to file</a>

View File

@ -6,9 +6,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
var c = fc.credentials;
$scope.csvReady = false;
$scope.csvHistory = function(isUpdating, cb) {
if (isUpdating) return;
$scope.csvHistory = function(cb) {
var allTxs = [];
function getHistory(cb) {

View File

@ -16,9 +16,10 @@ describe('Backup Controller', function() {
it('should be defined', function() {
should.exist(ctrl);
});
it('should set the mnemonic incomplete wallets', function(done) {
should.exist(ctrl);
ctrl.mnemonicWords.should.deep.equal('dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero'.split(' '));
should.exist(scope.mnemonicWords);
scope.mnemonicWords.should.deep.equal('dizzy cycle skirt decrease exotic fork sure mixture hair vapor copper hero'.split(' '));
done();
});
});
@ -35,11 +36,11 @@ describe('Backup Controller', function() {
});
it('should not set the mnemonic for complete wallets', function() {
ctrl.mnemonicWords.should.deep.equal('cheese where alarm job conduct donkey license pave congress pepper fence current'.split(' '));
scope.mnemonicWords.should.deep.equal('cheese where alarm job conduct donkey license pave congress pepper fence current'.split(' '));
});
it('should set main wallet info', function(done) {
ctrl.walletName.should.equal('kk');
scope.walletName.should.equal('kk');
done();
});
});

View File

@ -18,11 +18,17 @@ describe('Preferences History Controller', function() {
mocks.clear({}, done);
});
it('should be defined', function() {
should.exist(ctrl);
});
it('should export csv', function(done) {
ctrl.csvHistory(function(err) {
scope.csvHistory(function(err) {
should.not.exist(err);
ctrl.csvReady.should.equal(true);
JSON.stringify(ctrl.csvContent).should.equal('[{"Date":"2016-06-03T15:54:51.000Z","Destination":"","Description":"","Amount":"0.00120000","Currency":"BTC","Txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","Creator":"","Copayers":"","Comment":"just a comment"}]');
should.exist(scope.csvReady);
scope.csvReady.should.equal(true);
should.exist(scope.csvContent);
JSON.stringify(scope.csvContent).should.equal('[{"Date":"2016-06-03T15:54:51.000Z","Destination":"","Description":"","Amount":"0.00120000","Currency":"BTC","Txid":"bf31ecaa8e10ce57f9a889fc4c893b40ff57b016dd763957d942e21ed55fc62c","Creator":"","Copayers":"","Comment":"just a comment"}]');
done();
});
});