A suite to track Project Diva score statistics and ratings / D4DJ event data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
projectdivar/server/node_modules/twitter-autohook/test/bearer-token.js

43 lines
1020 B

const nock = require('nock');
const bearerToken = require('../bearer-token');
const assert = require('assert');
const tokenValue = 'access_token_from_api';
(async () => {
const scope = nock('https://api.twitter.com')
.post('/oauth2/token')
.reply(200, {token_type: 'bearer', access_token: 'access_token_from_api'});
let token = null;
await assert.doesNotReject(async () => {
token = await bearerToken({
consumer_key: 'test_consumer_key',
consumer_secret: 'test_consumer_secret',
});
});
assert.equal(token, tokenValue);
scope.done();
})();
(async () => {
const scope = nock('https://api.twitter.com')
.post('/oauth2/token')
.reply(503, {
errors: [{
message: 'test error',
code: 1337,
}],
});
await assert.rejects(async () => {
const token = await bearerToken({
consumer_key: 'test_consumer_key',
consumer_secret: 'test_consumer_secret',
});
}, {
name: 'BearerTokenError',
});
scope.done();
})();