login working on the UX

This commit is contained in:
Matias Alejo Garcia 2014-10-01 08:35:17 -03:00
commit 92f1bacf82
10 changed files with 125 additions and 72 deletions

View file

@ -83,6 +83,14 @@ describe('PayPro (in Wallet) model', function() {
c.networkName = walletConfig.networkName;
c.version = '0.0.1';
c.network = sinon.stub();
c.network.setHexNonce = sinon.stub();
c.network.setHexNonces = sinon.stub();
c.network.getHexNonce = sinon.stub();
c.network.getHexNonces = sinon.stub();
c.network.send = sinon.stub();
return new Wallet(c);
}
@ -683,9 +691,11 @@ describe('PayPro (in Wallet) model', function() {
});
});
it('#add tx proposal based on payment message via model', function(done) {
it('#add tx proposal based on payment message via model ', function(done) {
var w = ppw;
should.exist(w);
w.sendPaymentTx(w._ntxid, function(txid, merchantData) {
should.exist(txid);
should.exist(merchantData);

View file

@ -1894,12 +1894,13 @@ describe('Wallet model', function() {
var storage = new s();
var network = new Network(walletConfig.network);
var blockchain = new Blockchain(walletConfig.blockchain);
storage.setPassword = sinon.stub();
it('should fail to read an unexisting wallet', function(done) {
s.getFirst = sinon.stub().yields(null);
storage.getFirst = sinon.stub().yields(null);
Wallet.read('123', s, network, blockchain, [], function(err, w) {
Wallet.read('123', storage, network, blockchain, [], function(err, w) {
err.toString().should.contain('WNOTFOUND');
done();
});
@ -1907,25 +1908,25 @@ describe('Wallet model', function() {
it('should not read a corrupted wallet', function(done) {
s.getFirst = sinon.stub().yields(null, '{hola:1}');
storage.getFirst = sinon.stub().yields(null, '{hola:1}');
Wallet.read('123', s, network, blockchain, [], function(err, w) {
Wallet.read('123', storage, network, blockchain, [], function(err, w) {
err.toString().should.contain('WERROR');
done();
});
});
it('should read a wallet', function(done) {
s.getFirst = sinon.stub().yields(null, JSON.parse(o));
Wallet.read('123', s, network, blockchain, [], function(err, w) {
storage.getFirst = sinon.stub().yields(null, JSON.parse(o));
Wallet.read('123', storage, network, blockchain, [], function(err, w) {
should.not.exist(err);
done();
});
});
it('should be able to import unencrypted legacy wallet TxProposal: v0', function(done) {
s.getFirst = sinon.stub().yields(null, JSON.parse(legacyO));
Wallet.read('123', s, network, blockchain, [], function(err, w) {
storage.getFirst = sinon.stub().yields(null, JSON.parse(legacyO));
Wallet.read('123', storage, network, blockchain, [], function(err, w) {
should.exist(w);
w.id.should.equal('55d4bd062d32f90a');
should.exist(w.publicKeyRing.getCopayerId);
@ -1936,9 +1937,9 @@ describe('Wallet model', function() {
});
it('should be able to import simple 1-of-1 encrypted legacy testnet wallet', function(done) {
s.getFirst = sinon.stub().yields(null, JSON.parse(legacy1));
storage.getFirst = sinon.stub().yields(null, JSON.parse(legacy1));
Wallet.read('123', s, network, blockchain, [], function(err, w) {
Wallet.read('123', storage, network, blockchain, [], function(err, w) {
should.exist(w);
w.isReady().should.equal(true);
var wo = w.toObj();

View file

@ -33,10 +33,10 @@ describe('Identity model', function() {
beforeEach(function(done) {
storage = sinon.stub();
storage.getItem = sinon.stub();
storage.setPassphrase = sinon.spy();
storage.setPassword = sinon.spy();
storage.hasPassphrase = sinon.stub().returns(true);
storage.getSessionId = sinon.spy();
storage.setFromObj = sinon.spy();
storage.setLastOpened = sinon.stub().yields(null);
storage.deletePrefix = sinon.stub().yields(null);
Identity._newStorage = sinon.stub().returns(storage);
@ -127,14 +127,17 @@ describe('Identity model', function() {
describe('#open', function(done) {
beforeEach(function() {
Identity._createProfile = sinon.stub().callsArgWith(3, null, 'kk');
storage.getFirst = sinon.stub().yields('wallet1234');
profile.listWallets = sinon.stub().returns([{id:'walletid'}]);
Identity._openProfile = sinon.stub().callsArgWith(3, null, profile);
Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet);
});
it('should call ._createProfile', function(done) {
Identity.open(email, password, config, function(err, iden) {
it('should call ._openProfile', function(done) {
Identity.open(email, password, config, function(err, iden, w) {
Identity._openProfile.calledOnce.should.equal(true);
should.not.exist(err);
iden.profile.should.equal('kk');
Identity._createProfile.calledOnce.should.equal(true);
iden.profile.should.equal(profile);
done();
});
});
@ -154,7 +157,7 @@ describe('Identity model', function() {
it('should call .store from profile and wallets (2)', function(done) {
iden.profile.store = sinon.stub().yields(null);
iden.wallets = [{
iden.openWallets = [{
store: sinon.stub().yields(null)
}, {
store: sinon.stub().yields(null)
@ -162,8 +165,8 @@ describe('Identity model', function() {
iden.store({}, function(err) {
should.not.exist(err);
iden.profile.store.calledOnce.should.equal(true);
iden.wallets[0].store.calledOnce.should.equal(true);
iden.wallets[1].store.calledOnce.should.equal(true);
iden.openWallets[0].store.calledOnce.should.equal(true);
iden.openWallets[1].store.calledOnce.should.equal(true);
done();
});
});
@ -226,8 +229,7 @@ describe('Identity model', function() {
beforeEach(function() {
iden.migrateWallet = sinon.stub().yields(null);
iden.profile.setLastOpened = sinon.stub().yields(null);
iden.storage.setPassphrase = sinon.spy();
storage.setPassword = sinon.spy();
storage.getFirst = sinon.stub().yields('wallet1234');
var wallet = sinon.stub();
@ -236,14 +238,14 @@ describe('Identity model', function() {
Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet);
});
it('should call setPassphrase', function(done) {
it('should call setPassword', function(done) {
var s1 = sinon.stub();
s1.store = sinon.stub().yields(null);
iden.openWallet('id123', 'xxx', function(err, w) {
iden.storage.setPassphrase.calledOnce.should.equal(true);
iden.storage.setPassphrase.getCall(0).args[0].should.equal('xxx');
iden.storage.setPassword.calledOnce.should.equal(true);
iden.storage.setPassword.getCall(0).args[0].should.equal('xxx');
done();
});
});
@ -254,7 +256,7 @@ describe('Identity model', function() {
should.not.exist(err);
w.store.calledOnce.should.equal(true);
iden.profile.setLastOpenedTs.calledTwice.should.equal(true);
iden.migrateWallet.calledOnce.should.equal(true);
// iden.migrateWallet.calledOnce.should.equal(true);
done();
});
});
@ -332,7 +334,7 @@ describe('Identity model', function() {
var opts = {
secret: '8WtTuiFTkhP5ao7AF2QErSwV39Cbur6pdMebKzQXFqL59RscXM',
nickname: 'test',
passphrase: 'pass'
password: 'pass'
};
it('should yield bad network error', function(done) {

View file

@ -19,7 +19,7 @@ describe('Profile model', function() {
};
beforeEach(function() {
storage.setPassphrase = sinon.stub();
storage.setPassword = sinon.stub();
storage.set = sinon.stub();
storage.set.yields(null);
storage.get = sinon.stub().yields(null);