Skip to content

replaced assertion library should.js with chai.js #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,258 changes: 33 additions & 1,225 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
"type-is": "1.6.18"
},
"devDependencies": {
"chai": "^4.3.4",
"jshint": "2.13.0",
"mocha": "5.2.0",
"nyc": "^15.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove nyc? It's used for our coverage report. Please add it again in order to prevent follow-up issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwerre somehow nyc is stil removed, even after pulling development. Could you please add it again? It's just running npm install --save-dev nyc

"should": "13.2.3",
"sinon": "7.5.0"
},
"license": "MIT",
Expand Down
14 changes: 8 additions & 6 deletions test/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
* Module dependencies.
*/

var should = require('should');
var chai = require('chai');

/**
* SHA-1 assertion.
*/
chai.use(function (_chai, utils) {

should.Assertion.add('sha1', function() {
this.params = { operator: 'to be a valid SHA-1 hash' };

this.obj.should.match(/^[a-f0-9]{40}$/i);
}, true);
utils.addMethod(chai.Assertion.prototype, 'sha1', function (str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter says " 'str' is defined but never used."

var obj = utils.flag(this, 'object');
new chai.Assertion(obj).match(/^[a-f0-9]{40}$/i);
});

});
2 changes: 1 addition & 1 deletion test/integration/grant-types/abstract-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type');
var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error');
var Promise = require('bluebird');
var Request = require('../../../lib/request');
var should = require('should');
var should = require('chai').should();

/**
* Test `AbstractGrantType` integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var InvalidRequestError = require('../../../lib/errors/invalid-request-error');
var Promise = require('bluebird');
var Request = require('../../../lib/request');
var ServerError = require('../../../lib/errors/server-error');
var should = require('should');
var should = require('chai').should();

/**
* Test `AuthorizationCodeGrantType` integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error')
var InvalidGrantError = require('../../../lib/errors/invalid-grant-error');
var Promise = require('bluebird');
var Request = require('../../../lib/request');
var should = require('should');
var should = require('chai').should();

/**
* Test `ClientCredentialsGrantType` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/grant-types/password-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var InvalidRequestError = require('../../../lib/errors/invalid-request-error');
var PasswordGrantType = require('../../../lib/grant-types/password-grant-type');
var Promise = require('bluebird');
var Request = require('../../../lib/request');
var should = require('should');
var should = require('chai').should();

/**
* Test `PasswordGrantType` integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Promise = require('bluebird');
var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type');
var Request = require('../../../lib/request');
var ServerError = require('../../../lib/errors/server-error');
var should = require('should');
var should = require('chai').should();

/**
* Test `RefreshTokenGrantType` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/handlers/authenticate-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var Request = require('../../../lib/request');
var Response = require('../../../lib/response');
var ServerError = require('../../../lib/errors/server-error');
var UnauthorizedRequestError = require('../../../lib/errors/unauthorized-request-error');
var should = require('should');
var should = require('chai').should();

/**
* Test `AuthenticateHandler` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/handlers/authorize-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Request = require('../../../lib/request');
var Response = require('../../../lib/response');
var ServerError = require('../../../lib/errors/server-error');
var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error');
var should = require('should');
var should = require('chai').should();
var url = require('url');

/**
Expand Down
10 changes: 5 additions & 5 deletions test/integration/handlers/token-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var ServerError = require('../../../lib/errors/server-error');
var TokenHandler = require('../../../lib/handlers/token-handler');
var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error');
var UnsupportedGrantTypeError = require('../../../lib/errors/unsupported-grant-type-error');
var should = require('should');
var should = require('chai').should();
var util = require('util');

/**
Expand Down Expand Up @@ -121,8 +121,8 @@ describe('TokenHandler integration', function() {
saveToken: function() {}
};
var handler = new TokenHandler({ accessTokenLifetime: 120, extendedGrantTypes: extendedGrantTypes, model: model, refreshTokenLifetime: 120 });

handler.grantTypes.should.containEql(extendedGrantTypes);
console.log(handler.grantTypes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove console.log statements from code

handler.grantTypes.should.deep.include(extendedGrantTypes);
});

it('should set the `model`', function() {
Expand Down Expand Up @@ -997,8 +997,8 @@ describe('TokenHandler integration', function() {
};
var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 });
var tokenType = handler.getTokenType({ accessToken: 'foo', refreshToken: 'bar', scope: 'foobar' });

tokenType.should.containEql({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' });
console.log(tokenType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the console.log statements from code

tokenType.should.deep.include({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' });
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/integration/request_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var Request = require('../../lib/request');
var InvalidArgumentError = require('../../lib/errors/invalid-argument-error');
var should = require('should');
var should = require('chai').should();

/**
* Test `Request` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/response-types/code-response-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var CodeResponseType = require('../../../lib/response-types/code-response-type');
var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error');
var should = require('should');
var should = require('chai').should();
var url = require('url');

/**
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Promise = require('bluebird');
var Request = require('../../lib/request');
var Response = require('../../lib/response');
var Server = require('../../lib/server');
var should = require('should');
var should = require('chai').should();

/**
* Test `Server` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/token-types/bearer-token-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var BearerTokenType = require('../../../lib/token-types/bearer-token-type');
var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error');
var should = require('should');
var should = require('chai').should();

/**
* Test `BearerTokenType` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/utils/token-util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

var TokenUtil = require('../../../lib/utils/token-util');
var should = require('should');
var should = require('chai').should();

/**
* Test `TokenUtil` integration.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/grant-types/abstract-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `AbstractGrantType`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization
var Promise = require('bluebird');
var Request = require('../../../lib/request');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `AuthorizationCodeGrantType`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `ClientCredentialsGrantType`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/grant-types/password-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var PasswordGrantType = require('../../../lib/grant-types/password-grant-type');
var Request = require('../../../lib/request');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `PasswordGrantType`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/grant-types/refresh-token-grant-type_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type');
var Request = require('../../../lib/request');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `RefreshTokenGrantType`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/authenticate-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var AuthenticateHandler = require('../../../lib/handlers/authenticate-handler');
var Request = require('../../../lib/request');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();
var ServerError = require('../../../lib/errors/server-error');

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/authorize-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Request = require('../../../lib/request');
var Response = require('../../../lib/response');
var Promise = require('bluebird');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `AuthorizeHandler`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/token-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var Request = require('../../../lib/request');
var TokenHandler = require('../../../lib/handlers/token-handler');
var sinon = require('sinon');
var should = require('should');
var should = require('chai').should();

/**
* Test `TokenHandler`.
Expand Down
4 changes: 2 additions & 2 deletions test/unit/models/token-model_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var TokenModel = require('../../../lib/models/token-model');

var should = require('chai').should();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'should' is defined but never used.

/**
* Test `Server`.
*/
Expand All @@ -18,7 +18,7 @@ describe('Model', function() {
};

var model = new TokenModel(data);
model.accessTokenLifetime.should.be.Number;
model.accessTokenLifetime.should.a('number');
model.accessTokenLifetime.should.be.approximately(3600, 2);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/request_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

var Request = require('../../lib/request');
var should = require('should');
var should = require('chai').should();

/**
* Test `Request`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/response_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

var Response = require('../../lib/response');
var should = require('should');
var should = require('chai').should();

/**
* Test `Request`.
Expand Down