2019-01-21 16:17:36 +00:00
|
|
|
/* eslint-env node, mocha */
|
|
|
|
|
2018-12-22 13:10:40 +00:00
|
|
|
'use strict'
|
|
|
|
|
2019-01-21 16:17:36 +00:00
|
|
|
const assert = require('assert')
|
2019-03-03 13:55:14 +00:00
|
|
|
const mock = require('mock-require')
|
|
|
|
|
|
|
|
describe('generateAvatarURL() gravatar enabled', function () {
|
|
|
|
let avatars
|
|
|
|
beforeEach(function () {
|
|
|
|
// Reset config to make sure we don't influence other tests
|
|
|
|
let testconfig = {
|
|
|
|
allowGravatar: true,
|
|
|
|
serverURL: 'http://localhost:3000',
|
|
|
|
port: 3000
|
|
|
|
}
|
|
|
|
mock('../lib/config', testconfig)
|
|
|
|
avatars = mock.reRequire('../lib/letter-avatars')
|
|
|
|
})
|
2018-12-22 13:10:40 +00:00
|
|
|
|
2019-01-21 16:17:36 +00:00
|
|
|
it('should return correct urls', function () {
|
2019-03-17 22:47:30 +00:00
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', true), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?s=400')
|
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', false), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?s=96')
|
2019-01-21 16:17:36 +00:00
|
|
|
})
|
2019-03-03 13:55:14 +00:00
|
|
|
|
|
|
|
it('should return correct urls for names with spaces', function () {
|
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels'), 'http://localhost:3000/user/Daan%20Sprenkels/avatar.svg')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('generateAvatarURL() gravatar disabled', function () {
|
|
|
|
let avatars
|
|
|
|
beforeEach(function () {
|
|
|
|
// Reset config to make sure we don't influence other tests
|
|
|
|
let testconfig = {
|
|
|
|
allowGravatar: false,
|
|
|
|
serverURL: 'http://localhost:3000',
|
|
|
|
port: 3000
|
|
|
|
}
|
|
|
|
mock('../lib/config', testconfig)
|
|
|
|
avatars = mock.reRequire('../lib/letter-avatars')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should return correct urls', function () {
|
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', true), 'http://localhost:3000/user/Daan%20Sprenkels/avatar.svg')
|
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', false), 'http://localhost:3000/user/Daan%20Sprenkels/avatar.svg')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should return correct urls for names with spaces', function () {
|
|
|
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels'), 'http://localhost:3000/user/Daan%20Sprenkels/avatar.svg')
|
|
|
|
})
|
2019-01-21 16:17:36 +00:00
|
|
|
})
|