mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
9e96b04542
- this is a small part of a bit of cleanup of our test files - the goal is to make the existing tests clearer with a view to making it easier to write more tests - this makes the test structure follow the codebase structure more closely - eventually we will colocate the tests as we break the codebase down further
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
const sinon = require('sinon');
|
|
const models = require('../../../../core/server/models');
|
|
const configUtils = require('../../../utils/configUtils');
|
|
|
|
const config = configUtils.config;
|
|
|
|
describe('Unit: models/member', function () {
|
|
before(function () {
|
|
models.init();
|
|
});
|
|
|
|
beforeEach(function () {
|
|
config.set('assetHash', '1');
|
|
});
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
sinon.restore();
|
|
});
|
|
|
|
describe('toJSON', function () {
|
|
let toJSON;
|
|
|
|
beforeEach(function () {
|
|
toJSON = function (model, options) {
|
|
return new models.Member(model).toJSON(options);
|
|
};
|
|
});
|
|
|
|
it('avatar_image: generates gravatar url', function () {
|
|
const member = {
|
|
email: 'test@example.com'
|
|
};
|
|
|
|
config.set('privacy:useGravatar', true);
|
|
const json = toJSON(member);
|
|
|
|
json.avatar_image.should.eql(`https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=250&d=blank`);
|
|
});
|
|
|
|
it('avatar_image: skips gravatar when privacy.useGravatar=false', function () {
|
|
const member = {
|
|
email: 'test@example.com'
|
|
};
|
|
|
|
config.set('privacy:useGravatar', false);
|
|
const json = toJSON(member);
|
|
|
|
should(json.avatar_image).eql(null);
|
|
});
|
|
});
|
|
});
|