forked from bitpay/wallet
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the javascript unit tests to use PhantomJS 2
The javascript unit tests could not be made for a while because of an issue in the angular bitcore wallet client requiring phantomjs version 2. Since the new launcher was released a while ago already I updated the karma phantom launcher and created some example tests to prove we can create the tests again. I tested loading the entire copayApp module in the unit tests to see if everything was able to initialize. This worked, however the $log service currently dumps the entire stacktrace of where the $log method was called from in the console at the moment which creates a massive log every startup. This does not occur for the chrome launcher so it has something to do with the new phantomjs launcher. I don't think you want to load the entire module for unit testing anyway so I don't see that as a big problem as of now. It's nice that we can actually start testing the code.
- Loading branch information
1 parent
b42b157
commit 8476a19
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
'use strict'; | ||
|
||
describe('sidebarController', function(){ | ||
var scope, controller; | ||
describe('sidebarController tests', function(){ | ||
var scope, controller, profileService; | ||
|
||
beforeEach(angular.mock.module('copayApp.controllers')); | ||
beforeEach(function() { | ||
angular.mock.module('copayApp.controllers'); | ||
angular.mock.module('stateMock'); | ||
angular.mock.module('ngLodash'); | ||
angular.mock.module('copayApp.services'); | ||
angular.mock.module('bwcModule'); | ||
angular.mock.module('gettext'); | ||
angular.mock.module('angularMoment'); | ||
}); | ||
|
||
beforeEach( | ||
angular.mock.inject(function($rootScope, $controller, _profileService_) { | ||
profileService = _profileService_; | ||
scope = $rootScope.$new(); | ||
controller = $controller('sidebarController', { | ||
$scope: scope, | ||
profileService: profileService | ||
}); | ||
}) | ||
); | ||
|
||
it('wallet selection', function(){ | ||
expect(true).not.toBeUndefined(); | ||
it('wallet selection', function() { | ||
expect(controller).toBeDefined(); | ||
expect(controller.walletSelection).toBe(false); | ||
}); | ||
}); | ||
|
||
it('is able to switch wallets via the profile service.', function(){ | ||
spyOn(profileService, 'setAndStoreFocus'); | ||
var currentWalletId = '00000000-0000-0000-0000-000000000001'; | ||
var newWalletId = '00000000-0000-0000-0000-000000000002'; | ||
|
||
controller.switchWallet(newWalletId, currentWalletId); | ||
|
||
expect(profileService.setAndStoreFocus).toHaveBeenCalled(); | ||
expect(profileService.setAndStoreFocus) | ||
.toHaveBeenCalledWith(newWalletId, jasmine.any(Function)); | ||
}); | ||
|
||
it('does not switch wallets when the new wallet is already the current wallet', | ||
function() { | ||
spyOn(profileService, 'setAndStoreFocus'); | ||
var currentWalletId = '00000000-0000-0000-0000-000000000001'; | ||
|
||
controller.switchWallet(currentWalletId, currentWalletId); | ||
|
||
expect(profileService.setAndStoreFocus).not.toHaveBeenCalled(); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters