mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Update newGroup spec helper
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Groups Controller', function() {
|
describe('Groups Controller', function() {
|
||||||
var scope, ctrl, groups, user, guild, party, $rootScope;
|
var scope, ctrl, groups, user, guild, $rootScope;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
@@ -24,11 +24,12 @@ describe('Groups Controller', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("isMemberOfGroup", function() {
|
describe("isMemberOfGroup", function() {
|
||||||
it("returns true if group is the user's party", function() {
|
it("returns true if group is the user's party retrieved from groups service", function() {
|
||||||
party = specHelper.newGroup("test-party");
|
var party = specHelper.newGroup({
|
||||||
party._id = "unique-party-id";
|
_id: "unique-party-id",
|
||||||
party.type = 'party';
|
type: 'party',
|
||||||
party.members = []; // Ensure we wouldn't pass automatically.
|
members: ['leader-id'] // Ensure we wouldn't pass automatically.
|
||||||
|
});
|
||||||
|
|
||||||
var partyStub = sandbox.stub(groups,"party", function() {
|
var partyStub = sandbox.stub(groups,"party", function() {
|
||||||
return party;
|
return party;
|
||||||
@@ -39,10 +40,11 @@ describe('Groups Controller', function() {
|
|||||||
|
|
||||||
it('returns true if guild is included in myGuilds call', function(){
|
it('returns true if guild is included in myGuilds call', function(){
|
||||||
|
|
||||||
guild = specHelper.newGroup("leaders-user-id");
|
var guild = specHelper.newGroup({
|
||||||
guild._id = "unique-guild-id";
|
_id: "unique-guild-id",
|
||||||
guild.type = 'guild';
|
type: 'guild',
|
||||||
guild.members.push(user._id);
|
members: [user._id]
|
||||||
|
});
|
||||||
|
|
||||||
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
||||||
return [guild];
|
return [guild];
|
||||||
@@ -54,16 +56,18 @@ describe('Groups Controller', function() {
|
|||||||
|
|
||||||
it('does not return true if guild is not included in myGuilds call', function(){
|
it('does not return true if guild is not included in myGuilds call', function(){
|
||||||
|
|
||||||
guild = specHelper.newGroup("leaders-user-id");
|
var guild = specHelper.newGroup({
|
||||||
guild._id = "unique-guild-id";
|
_id: "unique-guild-id",
|
||||||
guild.type = 'guild';
|
type: 'guild',
|
||||||
|
members: ['not-user-id']
|
||||||
|
});
|
||||||
|
|
||||||
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
var myGuilds = sandbox.stub(groups,"myGuilds", function() {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, guild)).to.not.be.ok;
|
expect(scope.isMemberOfGroup(user._id, guild)).to.not.be.ok;
|
||||||
expect(myGuilds).to.be.called;
|
expect(myGuilds).to.be.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,19 +42,22 @@ var specHelper = {};
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newGroup(leader) {
|
function newGroup(overrides) {
|
||||||
var quest = { progress: { }, active: false };
|
var quest = { progress: { }, active: false };
|
||||||
group = {
|
group = {
|
||||||
"leader" : leader,
|
_id: 'group-id',
|
||||||
"quest" : quest,
|
leader : 'leader-id',
|
||||||
"memberCount" : 1,
|
memberCount : 1,
|
||||||
"chat" : [],
|
chat : [],
|
||||||
"privacy" : "public",
|
privacy : "public",
|
||||||
"invites" : [],
|
invites : [],
|
||||||
"members" : [
|
members : [
|
||||||
leader
|
'leader-id'
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_setOverrides(group, overrides);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user