mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #167 from cmgustavo/matias/bws1-fixtest
Fix karma test with ui-router
This commit is contained in:
commit
2fcae51275
|
@ -21,13 +21,7 @@
|
|||
"angular-bitcore-wallet-client": "^0.0.14",
|
||||
"angular-ui-router": "~0.2.13",
|
||||
"qrcode-decoder-js": "*",
|
||||
"angular-moment": "~0.7.1",
|
||||
"socket.io-client": ">=1.0.0",
|
||||
"ng-idle": "~1.0.2",
|
||||
"inherits": "~0.0.1",
|
||||
"lodash": "~2.4.1",
|
||||
"angular-gravatar": "*",
|
||||
"angular-touch": "~1.3.0"
|
||||
"angular-ui-switch": "~0.1.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"qrcode-generator": "0.0.1"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
describe('menuController', function(){
|
||||
var scope, controller;
|
||||
var state, scope, controller;
|
||||
|
||||
beforeEach(angular.mock.module('copayApp.controllers'));
|
||||
beforeEach(angular.mock.inject(function($rootScope, $controller){
|
||||
beforeEach(angular.mock.module('stateMock'));
|
||||
beforeEach(angular.mock.inject(function($rootScope, $controller, $state){
|
||||
state = $state;
|
||||
scope = $rootScope.$new();
|
||||
controller = $controller('menuController', {$scope: scope});
|
||||
}));
|
||||
|
|
|
@ -15,7 +15,10 @@ module.exports = function(config) {
|
|||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'bower_components/moment/moment.js',
|
||||
'bower_components/fastclick/lib/fastclick.js',
|
||||
'bower_components/qrcode-generator/js/qrcode.js',
|
||||
'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js',
|
||||
'bower_components/moment/min/moment-with-locales.js',
|
||||
'bower_components/angular/angular.js',
|
||||
'bower_components/angular-ui-router/release/angular-ui-router.js',
|
||||
'bower_components/angular-local-storage/dist/angular-local-storage.js',
|
||||
|
@ -27,7 +30,7 @@ module.exports = function(config) {
|
|||
'bower_components/angular-qrcode/qrcode.js',
|
||||
'bower_components/angular-gettext/dist/angular-gettext.js',
|
||||
'bower_components/angular-touch/angular-touch.js',
|
||||
'bower_components/buffer/buffer.js',
|
||||
'bower_components/angular-ui-switch/angular-ui-switch.js',
|
||||
'node_modules/angular-mocks/angular-mocks.js',
|
||||
'src/js/**/*.js',
|
||||
'test/**/*.js'
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
angular.module('stateMock',[]);
|
||||
angular.module('stateMock').service("$state", function($q){
|
||||
this.expectedTransitions = [];
|
||||
this.transitionTo = function(stateName){
|
||||
if(this.expectedTransitions.length > 0){
|
||||
var expectedState = this.expectedTransitions.shift();
|
||||
if(expectedState !== stateName){
|
||||
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
|
||||
}
|
||||
}else{
|
||||
throw Error("No more transitions were expected! Tried to transition to "+ stateName );
|
||||
}
|
||||
console.log("Mock transition to: " + stateName);
|
||||
var deferred = $q.defer();
|
||||
var promise = deferred.promise;
|
||||
deferred.resolve();
|
||||
return promise;
|
||||
}
|
||||
this.go = this.transitionTo;
|
||||
this.expectTransitionTo = function(stateName){
|
||||
this.expectedTransitions.push(stateName);
|
||||
}
|
||||
|
||||
|
||||
this.ensureAllTransitionsHappened = function(){
|
||||
if(this.expectedTransitions.length > 0){
|
||||
throw Error("Not all transitions happened!");
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue