YouAndWeb_TwoToc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
'use strict';
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!');
}
};
});
|
Revision |
Author |
Commited |
Message |
a2ecfb ...
|
PTKDev |
Fri 20 Nov, 2015 11:22:35 +0000 |
|