chai-as-promised 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -144,7 +144,7 @@ Promise.resolve(2).should.eventually.be.within(Promise.resolve(1), Promise.resol
144
144
 
145
145
  ### Compatibility
146
146
 
147
- Chai as Promised is compatible with all promises following the [Promises/A+ specification][spec]. Notably, jQuery's so-called “promises are not up to spec, and Chai as Promised will not work with them. In particular, Chai as Promised makes extensive use of the standard [transformation behavior][] of `then`, which jQuery does not support.
147
+ Chai as Promised is compatible with all promises following the [Promises/A+ specification][spec]. Notably, jQuery's promises were not up to spec before jQuery 3.0, and Chai as Promised will not work with them. In particular, Chai as Promised makes extensive use of the standard [transformation behavior][] of `then`, which jQuery<3.0 does not support.
148
148
 
149
149
  ### Working with Non-Promise–Friendly Test Runners
150
150
 
@@ -34,8 +34,11 @@
34
34
  var Assertion = chai.Assertion;
35
35
  var assert = chai.assert;
36
36
 
37
- function isJQueryPromise(thenable) {
38
- return typeof thenable.always === "function" &&
37
+ function isLegacyJQueryPromise(thenable) {
38
+ // jQuery promises are Promises/A+-compatible since 3.0.0. jQuery 3.0.0 is also the first version
39
+ // to define the catch method.
40
+ return typeof thenable.catch !== "function" &&
41
+ typeof thenable.always === "function" &&
39
42
  typeof thenable.done === "function" &&
40
43
  typeof thenable.fail === "function" &&
41
44
  typeof thenable.pipe === "function" &&
@@ -47,9 +50,10 @@
47
50
  if (typeof assertion._obj.then !== "function") {
48
51
  throw new TypeError(utils.inspect(assertion._obj) + " is not a thenable.");
49
52
  }
50
- if (isJQueryPromise(assertion._obj)) {
51
- throw new TypeError("Chai as Promised is incompatible with jQuery's thenables, sorry! Please use a " +
52
- "Promises/A+ compatible library (see http://promisesaplus.com/).");
53
+ if (isLegacyJQueryPromise(assertion._obj)) {
54
+ throw new TypeError("Chai as Promised is incompatible with thenables of jQuery<3.0.0, sorry! Please " +
55
+ "upgrade jQuery or use another Promises/A+ compatible library (see " +
56
+ "http://promisesaplus.com/).");
53
57
  }
54
58
  }
55
59
 
package/package.json CHANGED
@@ -1,46 +1,47 @@
1
1
  {
2
- "name": "chai-as-promised",
3
- "description": "Extends Chai with assertions about promises.",
4
- "keywords": [
5
- "chai",
6
- "chai-plugin",
7
- "browser",
8
- "async",
9
- "testing",
10
- "assertions",
11
- "promises",
12
- "promises-aplus"
13
- ],
14
- "version": "5.2.0",
15
- "author": "Domenic Denicola <d@domenic.me> (https://domenic.me)",
16
- "license": "WTFPL",
17
- "repository": "domenic/chai-as-promised",
18
- "main": "./lib/chai-as-promised.js",
19
- "files": [
20
- "lib"
21
- ],
22
- "scripts": {
23
- "test": "npm run test-plugin && npm run test-intercompatibility",
24
- "test-plugin": "mocha",
25
- "test-intercompatibility": "mocha test-intercompatibility --opts test-intercompatibility/mocha.opts",
26
- "test-browser-q": "coffee ./test/browser/runner.coffee q",
27
- "test-browser-when": "coffee ./test/browser/runner.coffee when",
28
- "lint": "jshint ./lib",
29
- "cover": "istanbul cover node_modules/mocha/bin/_mocha && opener ./coverage/lcov-report/lib/chai-as-promised.js.html"
30
- },
31
- "peerDependencies": {
32
- "chai": ">= 2.1.2 < 4"
33
- },
34
- "devDependencies": {
35
- "chai": "^3.0.0",
36
- "coffee-script": "1.10.0",
37
- "istanbul": "0.4.1",
38
- "ecstatic": "^1.3.1",
39
- "glob": "^6.0.1",
40
- "jshint": "^2.8.0",
41
- "mocha": "^2.3.4",
42
- "opener": "^1.4.1",
43
- "q": "^1.4.1",
44
- "underscore": "1.8.3"
45
- }
2
+ "name": "chai-as-promised",
3
+ "description": "Extends Chai with assertions about promises.",
4
+ "keywords": [
5
+ "chai",
6
+ "chai-plugin",
7
+ "browser",
8
+ "async",
9
+ "testing",
10
+ "assertions",
11
+ "promises",
12
+ "promises-aplus"
13
+ ],
14
+ "version": "5.3.0",
15
+ "author": "Domenic Denicola <d@domenic.me> (https://domenic.me)",
16
+ "license": "WTFPL",
17
+ "repository": "domenic/chai-as-promised",
18
+ "main": "./lib/chai-as-promised.js",
19
+ "files": [
20
+ "lib"
21
+ ],
22
+ "scripts": {
23
+ "test": "npm run test-plugin && npm run test-intercompatibility",
24
+ "test-plugin": "mocha",
25
+ "test-intercompatibility": "mocha test-intercompatibility --opts test-intercompatibility/mocha.opts",
26
+ "test-browser-jquery": "coffee ./test/browser/runner.coffee jquery",
27
+ "test-browser-q": "coffee ./test/browser/runner.coffee q",
28
+ "test-browser-when": "coffee ./test/browser/runner.coffee when",
29
+ "lint": "jshint ./lib",
30
+ "cover": "istanbul cover node_modules/mocha/bin/_mocha && opener ./coverage/lcov-report/lib/chai-as-promised.js.html"
31
+ },
32
+ "peerDependencies": {
33
+ "chai": ">= 2.1.2 < 4"
34
+ },
35
+ "devDependencies": {
36
+ "chai": "^3.0.0",
37
+ "coffee-script": "1.10.0",
38
+ "istanbul": "0.4.1",
39
+ "ecstatic": "^1.3.1",
40
+ "glob": "^6.0.1",
41
+ "jshint": "^2.8.0",
42
+ "mocha": "^2.3.4",
43
+ "opener": "^1.4.1",
44
+ "q": "^1.4.1",
45
+ "underscore": "1.8.3"
46
+ }
46
47
  }