mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
7f1d3ebc07
- move all test files from core/test to test/ - updated all imports and other references - all code inside of core/ is then application code - tests are correctly at the root level - consistent with other repos/projects Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
var should = require('should'),
|
|
nock = require('nock'),
|
|
configUtils = require('../../../utils/configUtils'),
|
|
gravatar = require('../../../../core/server/lib/image/gravatar');
|
|
|
|
describe('lib/image: gravatar', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('privacy:useGravatar', true);
|
|
});
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
});
|
|
|
|
it('can successfully lookup a gravatar url', function (done) {
|
|
nock('https://www.gravatar.com')
|
|
.get('/avatar/ef6dcde5c99bb8f685dd451ccc3e050a?s=250&d=404&r=x')
|
|
.reply(200);
|
|
|
|
gravatar.lookup({email: 'exists@example.com'}).then(function (result) {
|
|
should.exist(result);
|
|
should.exist(result.image);
|
|
result.image.should.eql('//www.gravatar.com/avatar/ef6dcde5c99bb8f685dd451ccc3e050a?s=250&d=mm&r=x');
|
|
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
|
|
it('can handle a non existant gravatar', function (done) {
|
|
nock('https://www.gravatar.com')
|
|
.get('/avatar/3a2963a39ebba98fb0724a1db2f13d63?s=250&d=404&r=x')
|
|
.reply(404);
|
|
|
|
gravatar.lookup({email: 'invalid@example.com'}).then(function (result) {
|
|
should.exist(result);
|
|
should.not.exist(result.image);
|
|
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
|
|
it('will timeout', function (done) {
|
|
nock('https://www.gravatar.com')
|
|
.get('/avatar/ef6dcde5c99bb8f685dd451ccc3e050a?s=250&d=404&r=x')
|
|
.delay(15)
|
|
.reply(200);
|
|
|
|
gravatar.lookup({email: 'exists@example.com'}, 10).then(function (result) {
|
|
should.not.exist(result);
|
|
done();
|
|
}).catch(done);
|
|
});
|
|
});
|