fix ALL karma + mocha tests, + karma integration

This commit is contained in:
Matias Alejo Garcia 2014-10-29 22:54:48 -03:00
commit ae4dd9a54b
4 changed files with 205 additions and 162 deletions

View file

@ -60,10 +60,8 @@ module.exports = function(config) {
//test files
'setup/karma.js',
'test/*.js',
'test/unit/**/*.js',
'test/*.js',
],

View file

@ -25,9 +25,8 @@ describe("Unit: Controllers", function() {
var scope;
var server;
beforeEach(module('copayApp.services'));
beforeEach(module('copayApp'));
beforeEach(module('copayApp.controllers'));
beforeEach(angular.mock.module('copayApp'));
beforeEach(module(function($provide) {
$provide.value('request', {
'get': function(_, cb) {

View file

@ -2,9 +2,54 @@
//
// test/unit/filters/filtersSpec.js
//
describe('Unit: Testing Filters', function() {
describe('Angular Filters', function() {
beforeEach(angular.mock.module('copayApp'));
beforeEach(module('copayApp.filters'));
beforeEach(inject(function($rootScope) {
var w = {};
w.isReady = sinon.stub().returns(true);
w.privateKey = {};
w.settings = {
unitToSatoshi: 100,
unitDecimals: 2,
alternativeName: 'US Dollar',
alternativeIsoCode: 'USD',
};
w.addressBook = {
'juan': '1',
};
w.balanceByAddr = [{
'address1': 1
}];
w.totalCopayers = 2;
w.getMyCopayerNickname = sinon.stub().returns('nickname');
w.getMyCopayerId = sinon.stub().returns('id');
w.privateKey.toObj = sinon.stub().returns({
wallet: 'mock'
});
w.getSecret = sinon.stub().returns('secret');
w.getName = sinon.stub().returns('fakeWallet');
w.getId = sinon.stub().returns('id');
w.exportEncrypted = sinon.stub().returns('1234567');
w.getTransactionHistory = sinon.stub().yields({});
w.getNetworkName = sinon.stub().returns('testnet');
w.getAddressesInfo = sinon.stub().returns({});
w.createTx = sinon.stub().yields(null);
w.sendTx = sinon.stub().yields(null);
w.requiresMultipleSignatures = sinon.stub().returns(true);
w.getTxProposals = sinon.stub().returns([1, 2, 3]);
$rootScope.wallet = w;
}));
var walletConfig = {
requiredCopayers: 3,
totalCopayers: 5,
@ -54,7 +99,6 @@ describe('Unit: Testing Filters', function() {
describe('noFractionNumber', function() {
describe('noFractionNumber bits', function() {
beforeEach(inject(function($rootScope) {
$rootScope.wallet = new FakeWallet(walletConfig);
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100;
w.settings.unitName = 'bits';
@ -73,7 +117,6 @@ describe('Unit: Testing Filters', function() {
describe('noFractionNumber BTC', function() {
beforeEach(inject(function($rootScope) {
$rootScope.wallet = new FakeWallet(walletConfig);
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100000000;
w.settings.unitName = 'BTC';
@ -93,7 +136,6 @@ describe('Unit: Testing Filters', function() {
describe('noFractionNumber mBTC', function() {
beforeEach(inject(function($rootScope) {
$rootScope.wallet = new FakeWallet(walletConfig);
var w = $rootScope.wallet;
w.settings.unitToSatoshi = 100000;
w.settings.unitName = 'mBTC';

View file

@ -6,9 +6,11 @@
var sinon = require('sinon');
var preconditions = require('preconditions').singleton();
beforeEach(angular.mock.module('copayApp'));
beforeEach(angular.mock.module('copayApp.services'));
beforeEach(module(function($provide) {
describe("Angular services", function() {
beforeEach(angular.mock.module('copayApp'));
beforeEach(angular.mock.module('copayApp.services'));
beforeEach(module(function($provide) {
$provide.value('request', {
'get': function(_, cb) {
cb(null, null, [{
@ -18,10 +20,10 @@ beforeEach(module(function($provide) {
}]);
}
});
}));
}));
beforeEach(inject(function($rootScope) {
beforeEach(inject(function($rootScope) {
var w = {};
w.isReady = sinon.stub().returns(true);
@ -58,11 +60,12 @@ beforeEach(inject(function($rootScope) {
w.requiresMultipleSignatures = sinon.stub().returns(true);
w.getTxProposals = sinon.stub().returns([1, 2, 3]);
$rootScope.wallet = w;
}));
}));
describe("Unit: controllerUtils", function() {
describe("Unit: controllerUtils", function() {
it('should updateBalance in bits', inject(function(controllerUtils, $rootScope) {
var w = $rootScope.wallet;
@ -97,15 +100,15 @@ describe("Unit: controllerUtils", function() {
expect($rootScope.unitName).to.be.equal('bits');
});
}));
});
});
describe("Unit: Notification Service", function() {
describe("Unit: Notification Service", function() {
it('should contain a notification service', inject(function(notification) {
expect(notification).not.to.equal(null);
}));
});
});
describe("Unit: Backup Service", function() {
describe("Unit: Backup Service", function() {
it('should contain a backup service', inject(function(backupService) {
expect(backupService).not.to.equal(null);
}));
@ -115,9 +118,9 @@ describe("Unit: Backup Service", function() {
backupService._download({}, 'test');
expectation.once();
}));
});
});
describe("Unit: isMobile Service", function() {
describe("Unit: isMobile Service", function() {
it('should contain a isMobile service', inject(function(isMobile) {
expect(isMobile).not.to.equal(null);
}));
@ -130,9 +133,9 @@ describe("Unit: isMobile Service", function() {
});
isMobile.any().should.equal(true);
}));
});
});
describe("Unit: uriHandler service", function() {
describe("Unit: uriHandler service", function() {
it('should contain a uriHandler service', inject(function(uriHandler) {
should.exist(uriHandler);
}));
@ -141,9 +144,9 @@ describe("Unit: uriHandler service", function() {
uriHandler.register();
}).should.not.throw();
}));
});
});
describe('Unit: Rate Service', function() {
describe('Unit: Rate Service', function() {
it('should be injected correctly', inject(function(rateService) {
should.exist(rateService);
}));
@ -172,4 +175,5 @@ describe('Unit: Rate Service', function() {
})
}
);
});
});