bwc
This commit is contained in:
parent
04fb7ba032
commit
320de62f13
348 changed files with 7745 additions and 30874 deletions
1112
test/old/controllersSpec.js
Normal file
1112
test/old/controllersSpec.js
Normal file
File diff suppressed because it is too large
Load diff
250
test/old/directivesSpec.js
Normal file
250
test/old/directivesSpec.js
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
'use strict';
|
||||
//
|
||||
// test/unit/directives/directivesSpec.js
|
||||
//
|
||||
describe("Unit: Testing Directives", function() {
|
||||
|
||||
var $scope, form;
|
||||
|
||||
beforeEach(module('copayApp.directives'));
|
||||
beforeEach(inject(function($rootScope) {
|
||||
|
||||
var w = {};
|
||||
w.isComplete = sinon.stub().returns(true);
|
||||
w.privateKey = {};
|
||||
w.settings = {
|
||||
unitToSatoshi: 100,
|
||||
unitDecimals: 2,
|
||||
alternativeName: 'US Dollar',
|
||||
alternativeIsoCode: 'USD',
|
||||
};
|
||||
w.addressBook = {
|
||||
'juan': '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.exportEncrypted = sinon.stub().returns('1234567');
|
||||
w.getTransactionHistory = sinon.stub().yields({});
|
||||
w.getNetworkName = sinon.stub().returns('testnet');
|
||||
|
||||
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;
|
||||
}));
|
||||
|
||||
describe('Validate Address', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
var element = angular.element(
|
||||
'<form name="form">' +
|
||||
'<input type="text" id="address" name="address" placeholder="Send to" ng-model="address" valid-address required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = {
|
||||
address: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
}));
|
||||
|
||||
it('should validate with network', inject(function($rootScope) {
|
||||
$rootScope.wallet.getNetworkName = sinon.stub().returns('testnet');
|
||||
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||
expect(form.address.$invalid).to.equal(false);
|
||||
}));
|
||||
it('should not validate with other network', inject(function($rootScope) {
|
||||
$rootScope.wallet.getNetworkName = sinon.stub().returns('livenet');
|
||||
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||
expect(form.address.$invalid).to.equal(true);
|
||||
}));
|
||||
it('should not validate random', function() {
|
||||
form.address.$setViewValue('thisisaninvalidaddress');
|
||||
expect(form.address.$invalid).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Validate Amount', function() {
|
||||
describe('Unit: bits', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
var element = angular.element(
|
||||
'<form name="form">' +
|
||||
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.00000001" max="10000000000" valid-amount required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = {
|
||||
amount: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
}));
|
||||
it('should validate', function() {
|
||||
form.amount.$setViewValue(100);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
form.amount.$setViewValue(800);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
form.amount.$setViewValue(900);
|
||||
|
||||
});
|
||||
|
||||
it('should not validate', function() {
|
||||
form.amount.$setViewValue(0);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(999999999999);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Unit: BTC', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
var w = $rootScope.wallet;
|
||||
w.settings.unitToSatoshi = 100000000;
|
||||
w.settings.unitName = 'BTC';
|
||||
w.settings.unitDecimals = 8;
|
||||
|
||||
$rootScope.availableBalance = 0.04;
|
||||
var element = angular.element(
|
||||
'<form name="form">' +
|
||||
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.00000001" max="10000000000" valid-amount required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = {
|
||||
amount: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
}));
|
||||
|
||||
it('should validate', function() {
|
||||
form.amount.$setViewValue(0.01);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
form.amount.$setViewValue(0.039);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
form.amount.$setViewValue(100292.039);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not validate', function() {
|
||||
form.amount.$setViewValue(0.039998888888888);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(0);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(0.0);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Contact directive', function() {
|
||||
var element1, element2;
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$rootScope.wallet = {
|
||||
addressBook: {
|
||||
'2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT': {
|
||||
label: ':)'
|
||||
}
|
||||
}
|
||||
}
|
||||
element1 = angular.element(
|
||||
'<contact address="2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT" />'
|
||||
);
|
||||
element2 = angular.element(
|
||||
'<contact address="2MvCKdnwEMiaexi247gi738U6pwUFZxbhXn" />'
|
||||
);
|
||||
$compile(element1)($rootScope);
|
||||
$compile(element2)($rootScope);
|
||||
$rootScope.$digest();
|
||||
}));
|
||||
|
||||
it('should replace the content', function() {
|
||||
expect(element1.html()).to.equal(':)');
|
||||
expect(element2.html()).to.equal('2MvCKdnwEMiaexi247gi738U6pwUFZxbhXn');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Password strength', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
var element = angular.element(
|
||||
'<input type="password" name="password" ng-model="password" check-strength="passwordStrength" value="asd" required>'
|
||||
);
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
}));
|
||||
|
||||
it('should check very weak password', function() {
|
||||
$scope.password = 'asd';
|
||||
$scope.$digest();
|
||||
expect($scope.passwordStrength.strength).to.equal(1);
|
||||
});
|
||||
|
||||
|
||||
it('should check weak password', function() {
|
||||
$scope.password = 'asdasdASDASD';
|
||||
$scope.$digest();
|
||||
expect($scope.passwordStrength.message).to.equal('Weak, add numerals');
|
||||
});
|
||||
|
||||
it('should check medium password', function() {
|
||||
$scope.password = 'asdasdA1';
|
||||
$scope.$digest();
|
||||
expect($scope.passwordStrength.message).to.equal('Medium, add punctuation');
|
||||
});
|
||||
|
||||
it('should check strong password', function() {
|
||||
$scope.password = 'asdasdASDASD1{';
|
||||
$scope.$digest();
|
||||
expect($scope.passwordStrength.message).to.equal('Strong, add punctuation');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Match Password Inputs', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
$rootScope.availableBalance = 1000;
|
||||
var element = angular.element(
|
||||
'<form name="form">' +
|
||||
'<input type="password" ng-model="walletPassword" name="walletPassword" required>' +
|
||||
'<input type="password" ng-model="walletPasswordConfirm" name="walletPasswordConfirm" match="walletPassword" required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = {
|
||||
walletPassword: null,
|
||||
walletPasswordConfirm: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
}));
|
||||
it('should not validate', function() {
|
||||
form.walletPassword.$setViewValue('mysecretpassword');
|
||||
form.walletPasswordConfirm.$setViewValue('mySecretPassword');
|
||||
$scope.$digest();
|
||||
expect(form.walletPasswordConfirm.$invalid).to.equal(true);
|
||||
});
|
||||
it('should validate', function() {
|
||||
form.walletPassword.$setViewValue('mysecretpassword123');
|
||||
form.walletPasswordConfirm.$setViewValue('mysecretpassword123');
|
||||
$scope.$digest();
|
||||
expect(form.walletPasswordConfirm.$invalid).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
168
test/old/filtersSpec.js
Normal file
168
test/old/filtersSpec.js
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
'use strict';
|
||||
//
|
||||
// test/unit/filters/filtersSpec.js
|
||||
//
|
||||
describe('Angular Filters', function() {
|
||||
|
||||
beforeEach(angular.mock.module('copayApp'));
|
||||
beforeEach(module('copayApp.filters'));
|
||||
beforeEach(inject(function($rootScope) {
|
||||
|
||||
var w = {};
|
||||
w.isComplete = 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,
|
||||
spendUnconfirmed: 1,
|
||||
reconnectDelay: 100,
|
||||
networkName: 'testnet',
|
||||
alternativeName: 'lol currency',
|
||||
alternativeIsoCode: 'LOL'
|
||||
};
|
||||
|
||||
|
||||
|
||||
describe('removeEmpty addresses', function() {
|
||||
it('should work with empty lists', inject(function($filter) {
|
||||
var removeEmpty = $filter('removeEmpty');
|
||||
expect(removeEmpty([]).length).to.equal(0);
|
||||
}));
|
||||
|
||||
it('should work with undefined', inject(function($filter) {
|
||||
var removeEmpty = $filter('removeEmpty');
|
||||
expect(removeEmpty(undefined).length).to.equal(0);
|
||||
}));
|
||||
|
||||
it('should filter empty change addresses from other copayers', inject(function($filter) {
|
||||
var removeEmpty = $filter('removeEmpty');
|
||||
var addresses = [{
|
||||
owned: true,
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}, {
|
||||
owned: false,
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}, {
|
||||
owned: true,
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}, {
|
||||
owned: false,
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}];
|
||||
expect(removeEmpty(addresses).length).to.equal(2);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('noFractionNumber', function() {
|
||||
describe('noFractionNumber bits', function() {
|
||||
beforeEach(inject(function($rootScope) {
|
||||
var w = $rootScope.wallet;
|
||||
w.settings.unitToSatoshi = 100;
|
||||
w.settings.unitName = 'bits';
|
||||
}));
|
||||
it('should format number to display correctly', inject(function($filter) {
|
||||
var noFraction = $filter('noFractionNumber');
|
||||
expect(noFraction(3100)).to.equal('3,100');
|
||||
expect(noFraction(3100200)).to.equal('3,100,200');
|
||||
expect(noFraction(3)).to.equal('3');
|
||||
expect(noFraction(0.3)).to.equal(0.3);
|
||||
expect(noFraction(0.30000000)).to.equal(0.3);
|
||||
expect(noFraction(3200.01)).to.equal('3,200.01');
|
||||
expect(noFraction(3200890.010000)).to.equal('3,200,890.01');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('noFractionNumber BTC', function() {
|
||||
beforeEach(inject(function($rootScope) {
|
||||
var w = $rootScope.wallet;
|
||||
w.settings.unitToSatoshi = 100000000;
|
||||
w.settings.unitName = 'BTC';
|
||||
}));
|
||||
it('should format number to display correctly', inject(function($filter) {
|
||||
var noFraction = $filter('noFractionNumber');
|
||||
expect(noFraction(0.30000000)).to.equal(0.3);
|
||||
expect(noFraction(0.00302000)).to.equal(0.00302);
|
||||
expect(noFraction(1.00000001)).to.equal(1.00000001);
|
||||
expect(noFraction(3.10000012)).to.equal(3.10000012);
|
||||
expect(noFraction(0.00100000)).to.equal(0.001);
|
||||
expect(noFraction(0.00100009)).to.equal(0.00100009);
|
||||
expect(noFraction(2000.00312011)).to.equal('2,000.00312011');
|
||||
expect(noFraction(2000998.00312011)).to.equal('2,000,998.00312011');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('noFractionNumber mBTC', function() {
|
||||
beforeEach(inject(function($rootScope) {
|
||||
var w = $rootScope.wallet;
|
||||
w.settings.unitToSatoshi = 100000;
|
||||
w.settings.unitName = 'mBTC';
|
||||
}));
|
||||
it('should format number to display correctly', inject(function($filter) {
|
||||
var noFraction = $filter('noFractionNumber');
|
||||
expect(noFraction(0.30000)).to.equal(0.3);
|
||||
expect(noFraction(0.00302)).to.equal(0.00302);
|
||||
expect(noFraction(1.00001)).to.equal(1.00001);
|
||||
expect(noFraction(3.10002)).to.equal(3.10002);
|
||||
expect(noFraction(0.00100000)).to.equal(0.001);
|
||||
expect(noFraction(0.00100009)).to.equal(0.001);
|
||||
expect(noFraction(2000.00312)).to.equal('2,000.00312');
|
||||
expect(noFraction(2000998.00312)).to.equal('2,000,998.00312');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('noFractionNumber:custom fractionSize', function() {
|
||||
it('should format number to display correctly', inject(function($filter) {
|
||||
var noFraction = $filter('noFractionNumber');
|
||||
expect(noFraction(0.30000, 0)).to.equal('0');
|
||||
expect(noFraction(1.00001, 0)).to.equal('1');
|
||||
expect(noFraction(3.10002, 0)).to.equal('3');
|
||||
expect(noFraction(2000.00312, 0)).to.equal('2,000');
|
||||
expect(noFraction(2000998.00312, 0)).to.equal('2,000,998');
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
215
test/old/servicesSpec.js
Normal file
215
test/old/servicesSpec.js
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
//
|
||||
// test/unit/services/servicesSpec.js
|
||||
//
|
||||
//
|
||||
//
|
||||
var sinon = require('sinon');
|
||||
var preconditions = require('preconditions').singleton();
|
||||
|
||||
|
||||
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, [{
|
||||
name: 'USD Dollars',
|
||||
code: 'USD',
|
||||
rate: 2
|
||||
}]);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
beforeEach(inject(function($rootScope) {
|
||||
|
||||
var w = {};
|
||||
w.isComplete = 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;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
describe("Unit: balanceService", function() {
|
||||
|
||||
it('should updateBalance in bits', inject(function(balanceService, $rootScope) {
|
||||
var w = $rootScope.wallet;
|
||||
|
||||
expect(balanceService.update).not.to.equal(null);
|
||||
var Waddr = Object.keys($rootScope.wallet.balanceByAddr)[0];
|
||||
var a = {};
|
||||
a[Waddr] = 200;
|
||||
w.getBalance = sinon.stub().yields(null, 100000001, a, 90000002, 5);
|
||||
|
||||
|
||||
//retuns values in DEFAULT UNIT(bits)
|
||||
balanceService.update(w, function() {
|
||||
var b = w.balanceInfo;
|
||||
expect(b.totalBalanceBTC).to.be.equal(1.00000001);
|
||||
expect(b.availableBalanceBTC).to.be.equal(0.90000002);
|
||||
expect(b.lockedBalanceBTC).to.be.equal(0.09999999);
|
||||
|
||||
expect(b.totalBalance).to.be.equal('1,000,000.01');
|
||||
expect(b.availableBalance).to.be.equal('900,000.02');
|
||||
expect(b.lockedBalance).to.be.equal('99,999.99');
|
||||
|
||||
expect(b.balanceByAddr[Waddr]).to.equal(2);
|
||||
expect(b.safeUnspentCount).to.equal(5);
|
||||
expect(b.topAmount).to.equal(899800.02);
|
||||
}, false);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe("Unit: Notification Service", function() {
|
||||
it('should contain a notification service', inject(function(notification) {
|
||||
expect(notification).not.to.equal(null);
|
||||
}));
|
||||
});
|
||||
|
||||
describe("Unit: identityService Service", function() {
|
||||
it('should contain a identityService service', inject(function(identityService) {
|
||||
expect(identityService).not.to.equal(null);
|
||||
}));
|
||||
});
|
||||
|
||||
describe("Unit: pinService", function() {
|
||||
it('should contain a pinService service', inject(function(pinService) {
|
||||
expect(pinService).not.to.equal(null);
|
||||
}));
|
||||
it('should be able to check -> save -> get -> clear -> check', function(done) {
|
||||
inject(function(pinService) {
|
||||
pinService.save('123', 'user', 'pass', function(err) {
|
||||
pinService.check(function(err, value) {
|
||||
should.not.exist(err);
|
||||
value.should.equal(true);
|
||||
pinService.get('123', function(err, data) {
|
||||
should.not.exist(err);
|
||||
data.email.should.be.equal('user');
|
||||
data.password.should.be.equal('pass');
|
||||
pinService.clear(function(err) {
|
||||
should.not.exist(err);
|
||||
pinService.check(function(err, value) {
|
||||
should.not.exist(err);
|
||||
value.should.equal(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("Unit: localstorageService", function() {
|
||||
it('should contain a localstorageService service', inject(function(localstorageService) {
|
||||
expect(localstorageService).not.to.equal(null);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe("Unit: Backup Service", function() {
|
||||
it('should contain a backup service', inject(function(backupService) {
|
||||
expect(backupService).not.to.equal(null);
|
||||
}));
|
||||
it('should backup in file', inject(function(backupService) {
|
||||
var mock = sinon.mock(window);
|
||||
var expectation = mock.expects('saveAs');
|
||||
backupService._download({}, 'test');
|
||||
expectation.once();
|
||||
}));
|
||||
});
|
||||
|
||||
describe("Unit: isMobile Service", function() {
|
||||
it('should contain a isMobile service', inject(function(isMobile) {
|
||||
expect(isMobile).not.to.equal(null);
|
||||
}));
|
||||
it('should not detect mobile by default', inject(function(isMobile) {
|
||||
isMobile.any().should.equal(false);
|
||||
}));
|
||||
it('should detect mobile if user agent is Android', inject(function(isMobile) {
|
||||
navigator.__defineGetter__('userAgent', function() {
|
||||
return 'Android 2.2.3';
|
||||
});
|
||||
isMobile.any().should.equal(true);
|
||||
}));
|
||||
});
|
||||
|
||||
describe("Unit: uriHandler service", function() {
|
||||
it('should contain a uriHandler service', inject(function(uriHandler) {
|
||||
should.exist(uriHandler);
|
||||
}));
|
||||
it('should register', inject(function(uriHandler) {
|
||||
(function() {
|
||||
uriHandler.register();
|
||||
}).should.not.throw();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Unit: Rate Service', function() {
|
||||
it('should be injected correctly', inject(function(rateService) {
|
||||
should.exist(rateService);
|
||||
}));
|
||||
it('should be possible to ask if it is available',
|
||||
inject(function(rateService) {
|
||||
should.exist(rateService.isAvailable);
|
||||
})
|
||||
);
|
||||
it('should be possible to ask for conversion from fiat',
|
||||
function(done) {
|
||||
inject(function(rateService) {
|
||||
rateService.whenAvailable(function() {
|
||||
(1e8).should.equal(rateService.fromFiat(2, 'USD'));
|
||||
done();
|
||||
});
|
||||
})
|
||||
}
|
||||
);
|
||||
it('should be possible to ask for conversion to fiat',
|
||||
function(done) {
|
||||
inject(function(rateService) {
|
||||
rateService.whenAvailable(function() {
|
||||
(2).should.equal(rateService.toFiat(1e8, 'USD'));
|
||||
done();
|
||||
});
|
||||
})
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue