This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 123
123
* you can treat promises attached to a scope as if they were the resulting values.
124
124
* - Q has many more features that $q, but that comes at a cost of bytes. $q is tiny, but contains
125
125
* all the important functionality needed for common async tasks.
126
+ *
127
+ * # Testing
128
+ *
129
+ * <pre>
130
+ * it('should simulate promise', inject(function($q, $rootSCope) {
131
+ * var deferred = $q.defer();
132
+ * var promise = deferred.promise;
133
+ * var resolvedValue;
134
+ *
135
+ * promise.then(function(value) { resolvedValue = value; });
136
+ * expect(resolvedValue).toBeUndefined();
137
+ *
138
+ * // Simulate resolving of promise
139
+ * defered.resolve(123);
140
+ * // Note that the 'then' function does not get called synchronously.
141
+ * // This is because we want the promise API to always be async, whether or not
142
+ * // it got called synchronously or asynchronously.
143
+ * expect(resolvedValue).toBeUndefined();
144
+ *
145
+ * // Propagate promise resolution to 'then' functions using $apply().
146
+ * $rootScope.$apply();
147
+ * expect(resolvedValue).toEqual(123);
148
+ * });
149
+ * </pre>
126
150
*/
127
151
function $QProvider ( ) {
128
152
You can’t perform that action at this time.
0 commit comments