mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Put isMemberOfGroup in its own describe block
This commit is contained in:
@@ -23,46 +23,48 @@ describe('Groups Controller', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("isMemberOfGroup returns true if group is the user's party", function() {
|
describe("isMemberOfGroup", function() {
|
||||||
party = specHelper.newGroup("test-party");
|
it("returns true if group is the user's party", function() {
|
||||||
party._id = "unique-party-id";
|
party = specHelper.newGroup("test-party");
|
||||||
party.type = 'party';
|
party._id = "unique-party-id";
|
||||||
party.members = []; // Ensure we wouldn't pass automatically.
|
party.type = 'party';
|
||||||
|
party.members = []; // Ensure we wouldn't pass automatically.
|
||||||
|
|
||||||
var partyStub = sinon.stub(groups,"party", function() {
|
var partyStub = sinon.stub(groups,"party", function() {
|
||||||
return party;
|
return party;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(scope.isMemberOfGroup(user._id, party)).to.be.ok;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, party)).to.be.ok;
|
it('returns true if guild is included in myGuilds call', function(){
|
||||||
});
|
|
||||||
|
|
||||||
it('isMemberOfGroup returns true if guild is included in myGuilds call', function(){
|
guild = specHelper.newGroup("leaders-user-id");
|
||||||
|
guild._id = "unique-guild-id";
|
||||||
|
guild.type = 'guild';
|
||||||
|
guild.members.push(user._id);
|
||||||
|
|
||||||
guild = specHelper.newGroup("leaders-user-id");
|
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
||||||
guild._id = "unique-guild-id";
|
return [guild];
|
||||||
guild.type = 'guild';
|
});
|
||||||
guild.members.push(user._id);
|
|
||||||
|
|
||||||
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
expect(scope.isMemberOfGroup(user._id, guild)).to.be.ok;
|
||||||
return [guild];
|
expect(myGuilds).to.be.called
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, guild)).to.be.ok;
|
it('does not return true if guild is not included in myGuilds call', function(){
|
||||||
expect(myGuilds).to.be.called
|
|
||||||
});
|
|
||||||
|
|
||||||
it('isMemberOfGroup does not return true if guild is not included in myGuilds call', function(){
|
guild = specHelper.newGroup("leaders-user-id");
|
||||||
|
guild._id = "unique-guild-id";
|
||||||
|
guild.type = 'guild';
|
||||||
|
|
||||||
guild = specHelper.newGroup("leaders-user-id");
|
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
||||||
guild._id = "unique-guild-id";
|
return [];
|
||||||
guild.type = 'guild';
|
});
|
||||||
|
|
||||||
var myGuilds = sinon.stub(groups,"myGuilds", function() {
|
expect(scope.isMemberOfGroup(user._id, guild)).to.not.be.ok;
|
||||||
return [];
|
expect(myGuilds).to.be.called
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scope.isMemberOfGroup(user._id, guild)).to.not.be.ok;
|
|
||||||
expect(myGuilds).to.be.called
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user