Commit 3676d7e1 authored by Hannah Stepanek's avatar Hannah Stepanek

Add common funcs for group-list-items

parent 228b0b12
'use strict';
function orgName(group) {
return group.organization && group.organization.name;
}
function trackViewGroupActivity(analytics) {
analytics.track(analytics.events.GROUP_VIEW_ACTIVITY);
}
module.exports = {
orgName,
trackViewGroupActivity,
};
'use strict';
const groupListItemCommon = require('../group-list-item-common');
const { events } = require('../../services/analytics');
describe('sidebar/util/groupListItemCommon', () => {
describe('trackViewGroupActivity', () => {
it('triggers the GROUP_VIEW_ACTIVITY event when called', () => {
const fakeAnalytics = {
track: sinon.stub(),
events,
};
groupListItemCommon.trackViewGroupActivity(fakeAnalytics);
assert.calledWith(
fakeAnalytics.track,
fakeAnalytics.events.GROUP_VIEW_ACTIVITY
);
});
});
describe('orgName', () => {
it('returns the organization name if it exists', () => {
const fakeGroup = { id: 'groupid', organization: { name: 'org' } };
const organizationName = groupListItemCommon.orgName(fakeGroup);
assert.equal(organizationName, fakeGroup.organization.name);
});
it('returns undefined if group has no organization', () => {
const fakeGroup = { id: 'groupid' };
assert.isUndefined(groupListItemCommon.orgName(fakeGroup));
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment