Last active
June 5, 2019 13:34
-
-
Save AndersDJohnson/4274664 to your computer and use it in GitHub Desktop.
chai plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ((plugin) -> | |
| # Module systems magic dance. | |
| if (typeof require == "function" && typeof exports == "object" && typeof module == "object") | |
| # NodeJS | |
| module.exports = plugin | |
| else if (typeof define == "function" && define.amd) | |
| # AMD | |
| define -> plugin | |
| else | |
| # Other environment (usually <script> tag): plug in to global chai instance directly. | |
| chai.use plugin | |
| )( | |
| (chai, utils) -> | |
| utils.addMethod(chai.assert, 'notInclude', ((haystack, needle) -> | |
| chai.assert( | |
| typeof haystack.indexOf is 'function' and haystack.length? | |
| 'expected first parameter to be an Array or String, but it wasn\'t' | |
| 'expected first parameter to be an Array or String, and it was' | |
| ) | |
| chai.assert( | |
| haystack.indexOf(needle) is -1 | |
| 'expected [' + haystack + '] not to include ' + needle + ', but it did' | |
| 'expected [' + haystack + '] not to include ' + needle + ', and it didn\'t' | |
| ) | |
| )) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment