mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
* wip: add guilds discovery page * add public guilds page * fix and add tests for the groups utilities mixin
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import groupsUtilities from 'client/mixins/groupsUtilities';
|
|
import { TAVERN_ID } from 'common/script/constants';
|
|
import Vue from 'vue';
|
|
|
|
describe('Groups Utilities Mixin', () => {
|
|
let instance, user;
|
|
|
|
before(() => {
|
|
instance = new Vue({
|
|
mixins: [groupsUtilities],
|
|
});
|
|
|
|
user = {
|
|
_id: '123',
|
|
party: {
|
|
_id: '456',
|
|
},
|
|
guilds: ['789'],
|
|
};
|
|
});
|
|
|
|
describe('isMemberOfGroup', () => {
|
|
it('registers as a method', () => {
|
|
expect(instance.isMemberOfGroup).to.be.a.function;
|
|
});
|
|
|
|
it('returns true when the group is the Tavern', () => {
|
|
expect(instance.isMemberOfGroup(user, {
|
|
_id: TAVERN_ID,
|
|
})).to.equal(true);
|
|
});
|
|
|
|
it('returns true when the group is the user\'s party', () => {
|
|
expect(instance.isMemberOfGroup(user, {
|
|
type: 'party',
|
|
_id: user.party._id,
|
|
})).to.equal(true);
|
|
});
|
|
|
|
it('returns false when the group is not the user\'s party', () => {
|
|
expect(instance.isMemberOfGroup(user, {
|
|
type: 'party',
|
|
_id: 'not my party',
|
|
})).to.equal(false);
|
|
});
|
|
|
|
it('returns true when the group is not a guild of which the user is a member', () => {
|
|
expect(instance.isMemberOfGroup(user, {
|
|
type: 'guild',
|
|
_id: user.guilds[0],
|
|
})).to.equal(true);
|
|
});
|
|
|
|
it('returns false when the group is not a guild of which the user is a member', () => {
|
|
expect(instance.isMemberOfGroup(user, {
|
|
type: 'guild',
|
|
_id: 'not my guild',
|
|
})).to.equal(false);
|
|
});
|
|
});
|
|
}); |