Successful test with amountController, using beforeEnter.
This commit is contained in:
parent
0db57f997a
commit
3df2836081
1 changed files with 54 additions and 8 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
fdescribe('amountController', function(){
|
describe('amountController', function(){
|
||||||
var $controller,
|
var configCache,
|
||||||
|
configService,
|
||||||
|
$controller,
|
||||||
|
$ionicHistory,
|
||||||
$rootScope,
|
$rootScope,
|
||||||
platformInfo,
|
platformInfo,
|
||||||
|
profileService,
|
||||||
|
rateService,
|
||||||
$stateParams;
|
$stateParams;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -10,12 +15,34 @@ fdescribe('amountController', function(){
|
||||||
module('ngLodash');
|
module('ngLodash');
|
||||||
module('copayApp.controllers');
|
module('copayApp.controllers');
|
||||||
|
|
||||||
|
configCache = {
|
||||||
|
wallet: {
|
||||||
|
settings: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
configService = jasmine.createSpyObj(['getDefaults','getSync']);
|
||||||
|
configService.getDefaults.and.returnValue({
|
||||||
|
bitcoinCashAlias: 'bch',
|
||||||
|
bitcoinAlias: 'btc'
|
||||||
|
});
|
||||||
|
configService.getSync.and.returnValue(configCache);
|
||||||
|
|
||||||
|
$ionicHistory = jasmine.createSpyObj(['backView']);
|
||||||
|
|
||||||
platformInfo = {
|
platformInfo = {
|
||||||
isChromeApp: false,
|
isChromeApp: false,
|
||||||
isAndroid: false,
|
isAndroid: false,
|
||||||
isIos: true
|
isIos: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
profileService = jasmine.createSpyObj(['getWallets']);
|
||||||
|
|
||||||
|
rateService = jasmine.createSpyObj(['fromFiat', 'whenAvailable']);
|
||||||
|
|
||||||
$stateParams = {};
|
$stateParams = {};
|
||||||
|
|
||||||
inject(function(_$controller_, _$rootScope_){
|
inject(function(_$controller_, _$rootScope_){
|
||||||
|
|
@ -28,20 +55,30 @@ fdescribe('amountController', function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('something', function() {
|
it('receives fromWalletId and toAddress.', function() {
|
||||||
|
|
||||||
|
var backView = {
|
||||||
|
stateName: 'ignoreme'
|
||||||
|
};
|
||||||
|
$ionicHistory.backView.and.returnValue(backView);
|
||||||
|
profileService.getWallets.and.returnValue([{}]);
|
||||||
|
rateService.fromFiat.and.returnValue(12); // satoshis or coins?
|
||||||
|
|
||||||
var $scope = $rootScope.$new();
|
var $scope = $rootScope.$new();
|
||||||
|
|
||||||
|
|
||||||
var amountController = $controller('amountController', {
|
var amountController = $controller('amountController', {
|
||||||
configService: {},
|
configService: configService,
|
||||||
gettextCatalog: {},
|
gettextCatalog: {},
|
||||||
$ionicHistory: {},
|
$ionicHistory: $ionicHistory,
|
||||||
$ionicModal: {},
|
$ionicModal: {},
|
||||||
$ionicScrollDelegate: {},
|
$ionicScrollDelegate: {},
|
||||||
nodeWebkitService: {},
|
nodeWebkitService: {},
|
||||||
ongoingProcess: {},
|
ongoingProcess: {},
|
||||||
platformInfo: platformInfo,
|
platformInfo: platformInfo,
|
||||||
profileService: {},
|
profileService: profileService,
|
||||||
popupService: {},
|
popupService: {},
|
||||||
rateService: {},
|
rateService: rateService,
|
||||||
$scope: $scope,
|
$scope: $scope,
|
||||||
$state: {},
|
$state: {},
|
||||||
$stateParams: $stateParams,
|
$stateParams: $stateParams,
|
||||||
|
|
@ -49,7 +86,16 @@ fdescribe('amountController', function(){
|
||||||
walletService: {}
|
walletService: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(true).toBe(true);
|
var data = {
|
||||||
|
stateParams: {
|
||||||
|
fromWalletId: 'fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b',
|
||||||
|
toAddress: 'qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$scope.$emit('$ionicView.beforeEnter', data);
|
||||||
|
|
||||||
|
expect($scope.fromWalletId).toBe('fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b');
|
||||||
|
expect($scope.toAddress).toBe('qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue