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(){
|
||||
var $controller,
|
||||
describe('amountController', function(){
|
||||
var configCache,
|
||||
configService,
|
||||
$controller,
|
||||
$ionicHistory,
|
||||
$rootScope,
|
||||
platformInfo,
|
||||
profileService,
|
||||
rateService,
|
||||
$stateParams;
|
||||
|
||||
|
||||
|
|
@ -10,12 +15,34 @@ fdescribe('amountController', function(){
|
|||
module('ngLodash');
|
||||
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 = {
|
||||
isChromeApp: false,
|
||||
isAndroid: false,
|
||||
isIos: true
|
||||
};
|
||||
|
||||
profileService = jasmine.createSpyObj(['getWallets']);
|
||||
|
||||
rateService = jasmine.createSpyObj(['fromFiat', 'whenAvailable']);
|
||||
|
||||
$stateParams = {};
|
||||
|
||||
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 amountController = $controller('amountController', {
|
||||
configService: {},
|
||||
configService: configService,
|
||||
gettextCatalog: {},
|
||||
$ionicHistory: {},
|
||||
$ionicHistory: $ionicHistory,
|
||||
$ionicModal: {},
|
||||
$ionicScrollDelegate: {},
|
||||
nodeWebkitService: {},
|
||||
ongoingProcess: {},
|
||||
platformInfo: platformInfo,
|
||||
profileService: {},
|
||||
profileService: profileService,
|
||||
popupService: {},
|
||||
rateService: {},
|
||||
rateService: rateService,
|
||||
$scope: $scope,
|
||||
$state: {},
|
||||
$stateParams: $stateParams,
|
||||
|
|
@ -49,7 +86,16 @@ fdescribe('amountController', function(){
|
|||
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