Skip to content

Commit

Permalink
Namespace extensions to Chai.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Nov 27, 2013
1 parent 21f19a1 commit 360b05e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -20,16 +20,15 @@ grants with the [Chai](http://chaijs.com/) assertion library.
Use this plugin as you would all other Chai plugins:

```javascript
var chai = require('chai')
, grant = require('chai-oauth2orize-grant');
var chai = require('chai');

chai.use(grant);
chai.use(require('chai-oauth2orize-grant'));
```

#### Write Test Cases

Once used, the `chai.grant` helper function will be available to set up test
cases for OAuth2orize grants.
Once used, the `chai.oauth2orize.grant` helper function will be available to set
up test cases for OAuth2orize grants.

## Tests

Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
@@ -1,7 +1,8 @@
module.exports = function(chai, _) {
var Test = require('./test');

chai.grant = function(mod) {
chai.oauth2orize = chai.oauth2orize || {};
chai.oauth2orize.grant = function(mod) {
return new Test(mod);
};
};
5 changes: 3 additions & 2 deletions test/plugin.test.js
Expand Up @@ -7,11 +7,12 @@ describe('helper', function() {
plugin(chai);

it('should add grant helper to chai', function() {
expect(chai.grant).to.be.a('function');
expect(chai.oauth2orize).to.be.an('object');
expect(chai.oauth2orize.grant).to.be.a('function');
});

describe('when invoked', function() {
var test = chai.grant({});
var test = chai.oauth2orize.grant({});

it('should return test wrapper', function() {
expect(test).to.be.an.instanceOf(Test);
Expand Down

0 comments on commit 360b05e

Please sign in to comment.