This commit is contained in:
Ivan Socolsky 2014-09-12 10:40:47 -03:00
commit 81a73e6f2a
5 changed files with 51 additions and 12 deletions

View file

@ -23,6 +23,7 @@ var FakeWallet = function() {
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC': 1000
};
this.name = 'myTESTwullet';
this.nickname = 'myNickname';
this.addressBook = {
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ': {
label: 'John',
@ -86,6 +87,10 @@ FakeWallet.prototype.getAddressesInfo = function() {
FakeWallet.prototype.subscribeToAddresses = function() {};
FakeWallet.prototype.getMyCopayerNickname = function() {
return this.nickname;
};
FakeWallet.prototype.isShared = function() {
return this.totalCopayers > 1;
}

View file

@ -1221,6 +1221,15 @@ describe('Wallet model', function() {
});
});
describe('#getMyCopayerNickname', function() {
it('should call publicKeyRing.nicknameForCopayer', function() {
var w = cachedCreateW2();
w.publicKeyRing.nicknameForCopayer = sinon.spy();
w.getMyCopayerNickname();
w.publicKeyRing.nicknameForCopayer.calledOnce.should.equal(true);
});
});
describe('#netStart', function() {
it('should call Network.start', function() {
var w = cachedCreateW2();

View file

@ -5,9 +5,11 @@
var sinon = require('sinon');
// Replace saveAs plugin
saveAsLastCall = null;
saveAs = function(o) {
saveAsLastCall = o;
saveAs = function(blob, filename) {
saveAsLastCall = {
blob: blob,
filename: filename
};
};
var startServer = require('../../mocks/FakePayProServer');
@ -35,6 +37,11 @@ describe("Unit: Controllers", function() {
};
describe('More Controller', function() {
it('Copay config should be binded', function() {
should.exist(config);
should.exist(config.unitToSatoshi);
});
var ctrl;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
@ -44,14 +51,22 @@ describe("Unit: Controllers", function() {
$scope: scope,
$modal: {},
});
saveAsLastCall = null;
}));
it('Backup controller #download', function() {
scope.wallet.setEnc('1234567');
expect(saveAsLastCall).equal(null);
scope.downloadBackup();
expect(saveAsLastCall.size).equal(7);
expect(saveAsLastCall.type).equal('text/plain;charset=utf-8');
expect(saveAsLastCall.blob.size).equal(7);
expect(saveAsLastCall.blob.type).equal('text/plain;charset=utf-8');
});
it('Backup controller should name backup correctly', function() {
scope.wallet.setEnc('1234567');
expect(saveAsLastCall).equal(null);
scope.downloadBackup();
expect(saveAsLastCall.filename).equal('myNickname-myTESTwullet-testID-keybackup.json.aes');
});
it('Backup controller #delete', function() {