Files
habitica/test/client/unit/specs/mixins/groupsUtilities.spec.js
Matteo Pagliazzi dc8598ae81 Client: Guilds Discovery (#8529)
* wip: add guilds discovery page

* add public guilds page

* fix and add tests for the groups utilities mixin
2017-03-03 19:38:17 +01:00

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);
});
});
});