2022-04-07 08:30:00 +05:30
|
|
|
const sinon = require('sinon');
|
|
|
|
const should = require('should');
|
|
|
|
const {formattedMemberResponse} = require('../../../../../core/server/services/members/utils');
|
|
|
|
const labs = require('../../../../../core/shared/labs');
|
|
|
|
|
|
|
|
describe('Members Service - utils', function () {
|
|
|
|
describe('formattedMemberResponse', function () {
|
|
|
|
let labsStub;
|
|
|
|
beforeEach(function () {
|
|
|
|
labsStub = sinon.stub(labs, 'isSet').returns(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns correct data', async function () {
|
|
|
|
const member1 = formattedMemberResponse({
|
|
|
|
uuid: 'uuid-1',
|
|
|
|
email: 'jamie+1@example.com',
|
|
|
|
name: 'Jamie Larson',
|
|
|
|
avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank',
|
|
|
|
subscribed: true,
|
|
|
|
status: 'free',
|
2022-07-07 14:17:50 +02:00
|
|
|
extra: 'property',
|
|
|
|
enable_comment_notifications: true
|
2022-04-07 08:30:00 +05:30
|
|
|
});
|
|
|
|
should(member1).deepEqual({
|
|
|
|
uuid: 'uuid-1',
|
|
|
|
email: 'jamie+1@example.com',
|
|
|
|
name: 'Jamie Larson',
|
|
|
|
firstname: 'Jamie',
|
|
|
|
avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank',
|
|
|
|
subscribed: true,
|
|
|
|
subscriptions: [],
|
2022-07-07 14:17:50 +02:00
|
|
|
paid: false,
|
|
|
|
enable_comment_notifications: true
|
2022-04-07 08:30:00 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('formats newsletter data', async function () {
|
|
|
|
const member1 = formattedMemberResponse({
|
|
|
|
uuid: 'uuid-1',
|
|
|
|
email: 'jamie+1@example.com',
|
|
|
|
name: 'Jamie Larson',
|
|
|
|
avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank',
|
|
|
|
subscribed: true,
|
|
|
|
status: 'comped',
|
|
|
|
extra: 'property',
|
|
|
|
newsletters: [{
|
|
|
|
id: 'newsletter-1',
|
|
|
|
name: 'Daily brief',
|
|
|
|
description: 'One email daily',
|
|
|
|
sender_name: 'Jamie',
|
|
|
|
sender_email: 'jamie@example.com',
|
|
|
|
sort_order: 0
|
2022-07-07 14:17:50 +02:00
|
|
|
}],
|
|
|
|
enable_comment_notifications: false
|
2022-04-07 08:30:00 +05:30
|
|
|
});
|
|
|
|
should(member1).deepEqual({
|
|
|
|
uuid: 'uuid-1',
|
|
|
|
email: 'jamie+1@example.com',
|
|
|
|
name: 'Jamie Larson',
|
|
|
|
firstname: 'Jamie',
|
|
|
|
avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank',
|
|
|
|
subscribed: true,
|
|
|
|
subscriptions: [],
|
|
|
|
paid: true,
|
|
|
|
newsletters: [{
|
|
|
|
id: 'newsletter-1',
|
|
|
|
name: 'Daily brief',
|
|
|
|
description: 'One email daily',
|
|
|
|
sort_order: 0
|
2022-07-07 14:17:50 +02:00
|
|
|
}],
|
|
|
|
enable_comment_notifications: false
|
2022-04-07 08:30:00 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|