Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1339c11

Browse files
lgalfasojeffbcross
authored andcommitted
refactor($q): make $q Promises A+ v1.1 compilant
The Promises A+ 1.1 spec introduces new constraints that would cause $q to fail, particularly specs 2.3.1 and 2.3.3. Newly satisfied requirements: * "then" functions that return the same fulfilled/rejected promise will fail with a TypeError * Support for edge cases where "then" is a value other than function Full 1.1 spec: https://github.com/promises-aplus/promises-spec/tree/1.1.0 This commit also modifies the adapter to use "resolve" method instead of "fulfill"
1 parent a603e20 commit 1339c11

File tree

5 files changed

+125
-183
lines changed

5 files changed

+125
-183
lines changed

lib/promises-aplus/promises-aplus-test-adapter.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33

44
var isFunction = function isFunction(value){return typeof value == 'function';};
55
var isPromiseLike = function isPromiseLike(obj) {return obj && isFunction(obj.then);};
6+
var isObject = function isObject(value){return value != null && typeof value === 'object';};
67

78
var $q = qFactory(process.nextTick, function noopExceptionHandler() {});
89

9-
exports.fulfilled = $q.resolve;
10+
exports.resolved = $q.resolve;
1011
exports.rejected = $q.reject;
11-
exports.pending = function () {
12+
exports.deferred = function () {
1213
var deferred = $q.defer();
1314

1415
return {
1516
promise: deferred.promise,
16-
fulfill: deferred.resolve,
17+
resolve: deferred.resolve,
1718
reject: deferred.reject
1819
};
1920
};

npm-shrinkwrap.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"protractor": "1.0.0",
3737
"yaml-js": "~0.0.8",
3838
"rewire": "1.1.3",
39-
"promises-aplus-tests": "~1.3.2",
39+
"promises-aplus-tests": "~2.0.4",
4040
"semver": "~2.1.0",
4141
"lodash": "~2.1.0",
4242
"browserstacktunnel-wrapper": "~1.1.1",

0 commit comments

Comments
 (0)