Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Automatically plug in to Chai in browser context.

  • Loading branch information...
commit d78f239ddb767b0f2800afc7ee533fcf8ab22857 1 parent 1120e3e
@domenic authored
View
3  .jshintrc
@@ -15,6 +15,7 @@
"indent": 4,
"predef": [
- "define"
+ "define",
+ "chai"
]
}
View
9 README.md
@@ -203,11 +203,12 @@ define(function (require, exports, module) {
### `<script>` tag
-If you include Chai as Promised directly with a `<script>` tag, it creates a `window.chaiAsPromised` global (again,
-just like Chai). Then your setup code becomes:
+If you include Chai as Promised directly with a `<script>` tag, after the one for Chai itself, then it will
+automatically plug in to Chai and be ready for use:
-```javascript
-window.chai.use(window.chaiAsPromised);
+```html
+<script src="chai.js"></script>
+<script src="chai-as-promised.js"></script>
```
View
5 lib/chai-as-promised.js
@@ -12,9 +12,8 @@
return chaiAsPromised;
});
} else {
- // Other environment (usually <script> tag): attach to global.
- var global = (false || eval)("this");
- global.chaiAsPromised = chaiAsPromised;
+ // Other environment (usually <script> tag): plug in to global chai instance directly.
+ chai.use(chaiAsPromised);
}
}(function chaiAsPromised(chai) {
"use strict";
View
1  test/support/browser.js
@@ -1,5 +1,4 @@
chai.should();
-chai.use(chaiAsPromised);
global.expect = chai.expect;
global.AssertionError = chai.AssertionError;
Please sign in to comment.
Something went wrong with that request. Please try again.