mojio-js-sdk
Version:
Mojio javascript REST client.
69 lines (61 loc) • 1.86 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var MojioAuth, async, nock, should;
MojioAuth = require('.././rest/MojioAuth');
should = require('should');
async = require('async');
nock = require('nock');
describe('Node Mojio Authentication', function() {
var testErrorResult;
testErrorResult = function(error, result) {
(error === null).should.be["true"];
return (result !== null).should.be["true"];
};
it('can authenticate via oauth code', function() {
var sdk;
sdk = new MojioAuth();
nock('https://accounts.moj.io').get("oauth2/authorize").reply(function(uri, requestBody, cb) {
return cb(null, [
200, {
id: 1
}
]);
});
return sdk.authorize("http://redirect.test.com/index.html", "full", function(error, result) {
testErrorResult(error, result);
return result.should.be.equal(url);
});
});
it('can get token', function() {
var sdk;
sdk = new MojioAuth();
nock('https://accounts.moj.io').get("Login").reply(function(uri, requestBody, cb) {
return cb(null, [
200, {
id: 1
}
]);
});
return sdk.token(function(error, result) {
testErrorResult(error, result);
return result.should.be.equal(url);
});
});
return it('can get login using token', function() {
var sdk;
sdk = new MojioAuth();
nock('https://accounts.moj.io').get("Login").reply(function(uri, requestBody, cb) {
return cb(null, [
200, {
id: 1
}
]);
});
return sdk.login(function(error, result) {
testErrorResult(error, result);
return result.should.be.equal(url);
});
});
});
}).call(this);
//# sourceMappingURL=NodeAuth_test.js.map