Files
kami-parse-server/spec/TwitterAuth.spec.js
Diamond Lewis e6ac3b6932 fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders.

Set max line length to be 100
2020-10-25 15:06:58 -05:00

98 lines
2.0 KiB
JavaScript

const twitter = require('../lib/Adapters/Auth/twitter');
describe('Twitter Auth', () => {
it('should use the proper configuration', () => {
// Multiple options, consumer_key found
expect(
twitter.handleMultipleConfigurations(
{
consumer_key: 'hello',
},
[
{
consumer_key: 'hello',
},
{
consumer_key: 'world',
},
]
).consumer_key
).toEqual('hello');
// Multiple options, consumer_key not found
expect(function () {
twitter.handleMultipleConfigurations(
{
consumer_key: 'some',
},
[
{
consumer_key: 'hello',
},
{
consumer_key: 'world',
},
]
);
}).toThrow();
// Multiple options, consumer_key not found
expect(function () {
twitter.handleMultipleConfigurations(
{
auth_token: 'token',
},
[
{
consumer_key: 'hello',
},
{
consumer_key: 'world',
},
]
);
}).toThrow();
// Single configuration and consumer_key set
expect(
twitter.handleMultipleConfigurations(
{
consumer_key: 'hello',
},
{
consumer_key: 'hello',
}
).consumer_key
).toEqual('hello');
// General case, only 1 config, no consumer_key set
expect(
twitter.handleMultipleConfigurations(
{
auth_token: 'token',
},
{
consumer_key: 'hello',
}
).consumer_key
).toEqual('hello');
});
it('Should fail with missing options', done => {
try {
twitter.validateAuthData(
{
consumer_key: 'key',
consumer_secret: 'secret',
auth_token: 'token',
auth_token_secret: 'secret',
},
undefined
);
} catch (error) {
jequal(error.message, 'Twitter auth configuration missing');
done();
}
});
});